lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <>
Subject Re: Grouping Clauses to Preserve Order of Boolean Precedence
Date Thu, 04 Aug 2011 15:47:42 GMT

: But the query parser doesn't seem to do that for me with the input Marketing
: AND Smith OR Davies. The query parser gives me 3 clauses. 1 must clause for

i didn't say the QueryParser would do that with *that* input

You asked...

: > : Thanks Ian. How would you achieve the logic of the below query using
: > : BooleanQuery and BooleanClause.occur? How would you achieve the grouping
: > : effect?
: > :
: > : (Marketing AND Smith) OR Davies

...and i said...

: > The same way the query parser does: that's a BooleanQuery (A) with two
: > "SHOULD" clauses, the first of which is a nested BooleanQuery (B) (with
: > two "MUST" clauses (X child of B) Marketing, and (Y child of B) Smith),
: > and the 2nd of which (C, child of A) is a query for Davies.

...which is exactly what the QueryParser would do given *that* input (with 

If you want to programaticlly build up a query with the structure you are 
describing, nested BooleanQuery objects is how you do it.


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

View raw message