Step 1, fully parenthesize your boolean to show your desired order of
execution. The Lucene BooleanQuery does not do a pure Boolean evaluation.
You have the same sub-expression in your NOT clause - that's probably what
guarantees zero results. And you have an unmatched right parenthesis at the
end.
Lucene BooleanQuery uses "SHOULD" (for "OR"), "MUST" (for "AND"), and
"MUST_NOT" ("NOT"). Very similar to a true Boolean expression except that
the clauses at any level of expression are not evaluated in order or AND/OR
precedence. If you need strict evaluation order, use parentheses (or
multi-level BooleanQuery at the Lucene Query level.)
Read more detail at:
http://searchhub.org/dev/2011/12/28/why-not-and-or-and-not/
-- Jack Krupansky
-----Original Message-----
From: heikki
Sent: Thursday, August 23, 2012 8:09 AM
To: java-user@lucene.apache.org
Subject: Question about BooleanQuery
hello,
I'm trying to construct a boolean query, but can't get it to return the
results that I intend. Does anyone see what I'm doing wrong ?
The query is like
The idea is that it should return documents where
someField_1 = 0 OR someField_2 = 0 AND booleanField_1 = false BUT NOT (
someField_1 = 0 OR someField_2 = 0) AND booleanField_2 = true )
The problem seems to be with the BUT NOT part of the query. I get no
results, even though I would have expected so (and I've checked the index
contents with Luke).
Any ideas most welcome ..
Kind regards
Heikki Doeleman
--
View this message in context:
http://lucene.472066.n3.nabble.com/Question-about-BooleanQuery-tp4002822.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org