lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Subject Re: How can you simulate inOrder in boolean queries
Date Wed, 08 Feb 2006 01:17:59 GMT
The source code to Lucene in Action ( has an  
example of extending the built-in QueryParser to use SpanNearQuery  
for in-order phrase searching instead of the default unordered  
PhraseQuery behavior.  That example will show how to use  
SpanNearQuery made up of SpanTermQuery's.  The source code to  
QueryParser < 
java/org/apache/lucene/queryParser/QueryParser.jj> shows how to use  
PhraseQuery directly, if all you want is an example.

Also as Paul mentioned, the test cases in Lucene's source code make  
great ways to learn how Lucene's API works.

If what you're trying to do is put an in-order wrapper around all of  
the query types you mentioned, you will have a fair bit more work to  
do in order to create a parser that can create a SpanNearQuery with  
SpanRegexQuery's (new in contrib's trunk), and there currently is not  
a SpanQuery version of FuzzyQuery that I'm aware of.


On Feb 7, 2006, at 4:06 PM, RONALD MANTAY wrote:

>     Hi, can any one help, I am new to lucene.
>   Due to requiring a specific Query syntax, I have created a  
> bespoke query parser to build a boolean query which at any time may  
> comprising a mixture of :
>   a)  Fuzzy terms with similarity level set according to length of  
> term.text
>   b)  Wild Card Querys
>   c)  Term Querys
>   I would like to ability to define if the Query parser terms  
> require to be in Order or not (but when in order to allow gaps in  
> the term positions).
>   I can not see see how I can use PhraseQuery or SpanNearQuery  
> directly, can anyone point me in the right direction in how to  
> simulate inOrder to boolean queries.
>   Any help will be appreciated.

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

View raw message