lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Swainston <>
Subject Re: Grouping Clauses to Preserve Order of Boolean Precedence
Date Thu, 04 Aug 2011 12:45:15 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
the term Marketing, 1 must clause for the term smith and 1 should clause for
the term Davies. e.g. +Marketing +Smith SHOULD Davies. What I would like the
query parser to be doing is recognising the order of Boolean precedence so
that it automatically gives me the nested query you describe e.g. SHOULD
(+Marketing +Smith) SHOULD Davies.

If Lucene can't do this does anyone know of any algorithms for generating
these nested queries so that they follow the order of Boolean precedence?

On 4 August 2011 02:05, Chris Hostetter <> wrote:

> : 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
> 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.
> -Hoss
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message