[hibernate-dev] Hibernate web search

2008-09-21 Thread Adam Warski

Hello,

one feature I find missing from Hibernate Search is a possibility to  
easily implement a web search.


A good example is a blog app, where you can search contents of posts.  
A post is a simple entity with a "body" field, which is indexed by  
Hibernate Search/Lucene.
You then have the normal search box, where the user enters his/hers  
query. And now is the problem: what do to with this query?


Solution 1.
Pass it unchanged to the query parser, as is done for example in the  
blog example in Seam. But that will in many cases generate exceptions.  
For example - when there is an unclosed " or a :. You can of course  
catch that exception and return to the user an empty result list - but  
that's not what the user excepts.


Solution 2.
Escape any special characters (using QueryParser.escape) and then pass  
it safely to query parser - but then the semantics of all special  
constructs (like phrases: "...", including/excluding words: +/-, fuzzy  
searches: ~ etc) stop to work. That is also not what the user expects.


My proposed solution.
The best way out, in my opinion, is to create a custom query pre- 
parser. This parser would be very "forgiving" in case of any syntax  
errors.
I think it would be best to support the query syntax that google uses  
(that's what the users are accustomed to):

* standard boolean operators AND, OR
* quotes "..."
* fuzzy/synonym search ~ (but in front of the word, not in the end)
* word inclusion/exclusion: +/-

Some Lucene constructs would be disabled, like boosting (^), field- 
search (field_name:), *, ?.


Any special characters in invalid positions would be escaped, for  
example an unmatched quote or a + without a word following it. The  
parser wouldn't be only a syntax-repairer, but also perform other  
operations, like moving the ~ from the beginning of a word to the end,  
or (maybe) adding a * to the end of each term.


The implementation shouldn't be too complicated using either ANTLR/ 
JavaCC or simply regular expressions and a string builder.


Needless to say, this would also be useful in Seam :).

What do you think?

--
Adam

___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev


[hibernate-dev] Dialect Registration

2008-09-21 Thread Tomoto Shimizu Washio
Hi,

I have finished up a document and a patch for Dialect Registration
mechanism, and I posted them as an attachment to HHH-2933 which I think
was a related topic.
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2933

I have reached this design after trying to make it easy for users to
integrate optional or third-party dialects into their applications.
It might be a bit different from what you had had in your mind...

Hope it helps,
Tomoto


On Sat, 20 Sep 2008 02:27:42 +0900
Tomoto Shimizu Washio <[EMAIL PROTECTED]> wrote:

> Hi Steve,
> 
> On Thu, 18 Sep 2008 09:02:39 -0500
> Steve Ebersole <[EMAIL PROTECTED]> wrote:
> 
> > Dialect "registration" in DialectFactory would be fantastic.  It was
> > planned from the get-go, but I never had a chance to circle back around
> > to it.  Its not all that difficult.  But we should agree on a basic
> > format for the externalized definitions.
> 
> I have a design where each dialect implementation knows the database
> name and the version it can be applied to, and users just need to
> enumerate the dialect class names in the configuration file to register
> them.  If you were interested in this idea, I could write down the
> design sketch and/or the code and post them to this ML or JIRA.
> 
> > Like Chris said, we need to do an "extras" module anyway at some point.
> > So let us know if you'd like this Dialect added there when we do.
> 
> I appreciate your offer.  We will decide when the module comes. 
> Possibly we should not move the dialect to "extras" after it was
> released in jp.co.hitachi package and users started to use it.
> 
> Thanks,
> Tomoto
> 
> 
> > -  
> > 
> > Steve Ebersole
> > Project Lead
> > http://hibernate.org
> > [EMAIL PROTECTED]
> > 
> > Principal Software Engineer
> > JBoss, a division of Red Hat
> > http://jboss.com
> > http://redhat.com
> > [EMAIL PROTECTED]
> > [EMAIL PROTECTED]

___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev