lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Gilmartin <>
Subject Re: Custom Query Syntax/Parser
Date Mon, 28 Jan 2013 16:42:36 GMT
Uwe Schindler wrote:

> there is no need to extend Lucene's QueryParser. Lucene by 
> itself does not need a Query Parser at all and it does not 
> use it, it is just a convenience class. If you have worked 
> with Antlr to generate a grammar, just use it and build 
> the final in your code.

I would only add to that is that you might also consider being able to apply a Visitor pattern
to your resulting query. I do this so that applying query transformations -- like broadening
terms (w/ a lower boost) or adding bigrams -- is done consistently across all expression syntaxes.

When I first started using Lucene, Lucene's Query classes where not suitable for use with
the Visitor pattern and so I created my own query class equivalants and other more specialized
ones. Lucene's classes might have changed since then (I do not know), but I continue to use
my own set and several visitor implementations. The final visitor that I apply is the "convert
to Lucene query" transformation.

-- Andrew

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message