[hibernate-dev] Hibernate web search

Sanne Grinovero sanne.grinovero at gmail.com
Mon Sep 22 12:38:32 EDT 2008

Hello Adam,
I agree with you that the Seam example could include a better parser,
but that's just an example
and maybe they just wanted to keep it simple. As you say, there could
be a parser provided
with HSearch to keep the example code simple but what is missing in
your opinion?
Writing such a queryparser is really easy if you consider acceptable
to catch "QueryParseException"s
what I usually do in case of such an exception is report a JSF
validation error with some instructions about
query syntax.
The default query parser already supports AND and OR keywords, and by
extending it and overriding a simple method you can disable
the similarity symbol "~" if you want to (don't remember the method
name now but can look it up if you need it); this way the default
QueryParser already support all of google's basic syntax (excluding
the advanced fetatures, leaving out stuff like language and website

What is missing in your opinion? would you like to disable the feature
of specifying the fields? is there some feature missing?

kind regards,

2008/9/22 Adam Warski <adam at warski.org>:
> Hello,
>> in fact I was facing similar problems before, however the problem is more
>> of a Lucene problem than a Hibernate Search one.
> Sure, but it doesn't mean HS can't solve it :)
>> There are some threads regarding "error tolerant" query parsers on the
>> Lucene mailing list. There are several approaches to the problem.
>> You could catch the ParseException and inspect the error message.
>> According to some post it should be possible to extract the cause of the
>> error from the excpetion and maybe modify the query. A simpler approach
>> might be to use QueryParser.escape() in case a ParseException occurs and
>> just escape the whole query string.
> You're right, the parsing error is quite well described (not in string form,
> but "programatically") in the exception. So implementing what I wrote about
> earlier would be even easier that I suspected. I'll let you know when I'm
> done with it :).
>> I think just using QueryParser.parse() out of the box is most of the times
>> not sufficient and you always have to write some custom code around query
>> generation and handling. The question is whether any custom parser is
>> generic enough to be used in a wide range of applications. I like the idea
>> of a google
>> like query parser though. I wonder how Nutch is works in this area.
> Well, as I wrote, I think that supporting Google-like queries would be a
> good "generic" parser. If the user builds a simple searchable website (with
> Seam) and wants a "search" box to search through his content such a parser
> would be what he expects to have in HS (unless his needs are that simple to
> just send a "site:www.mysite.com query" query to google :) ).
> --
> Adam
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev

More information about the hibernate-dev mailing list