lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Subject Re: Query#rewrite Question
Date Thu, 11 Nov 2004 10:06:10 GMT

On Nov 10, 2004, at 9:51 PM, Satoshi Hasegawa wrote:
> Our program accepts input in the form of Lucene query syntax from the 
> user,
> but we wish to perform additional tasks such as thesaurus expansion. 
> So I
> want to manipulate the Query object that results from parsing.

You may want to consider using an Analyzer to expand queries rather 
than manipulating the query object itself.

> My question is, is the result of the Query#rewrite method guaranteed 
> to be
> either a TermQuery, a PhraseQuery, or a BooleanQuery, and if it is a
> BooleanQuery, do all the constituent clauses also reduce to one of the 
> above
> three classes?

No.  For example, look at the SpanQuery family.  These do no explicit 
rewriting and thus are left as themselves.

>  If not, what if the original Query object was the one that
> was obtained from QueryParser#parse method? Can I assume the above in 
> this
> restricted case?
> I experimented with the current version, and the above seems to be 
> positive
> in this version; I'm asking if this could change in the future. Thank 
> you.

I think we'll see QueryParser, or at least more sophisticated versions 
of it, emerge that support SpanQuery's.  In fact, in our book, I 
created a subclas of QueryParser that overrides getFieldQuery and 
returns a SpanNearQuery in order to achieve ordered phrase searching.


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

View raw message