Hi, Lucene does not use algebraic / boolean logic! Maybe review this blog post: https://lucidworks.com/blog/why-not-and-or-and-not/
As you see in your examples and how the wqueries are parsed, AND, OR, and NOT are mapped to something else: Lucene only knows if a term MUST be in results, or SHOULD be in results (at least one occurrence in total), or MUST_NOT. The Operators are applied to the clauses (terms) in Lucene. Uwe ----- Uwe Schindler H.-H.-Meier-Allee 63, D-28213 Bremen http://www.thetaphi.de eMail: u...@thetaphi.de > -----Original Message----- > From: Ian Koelliker [mailto:ikoelli...@axsone.com] > Sent: Friday, February 06, 2015 10:47 PM > To: java-user@lucene.apache.org > Subject: Lucene query behavior using NOT > > Hello, > I am trying to understand whether I am using the NOT operator correctly. I > have the following scenario: > > Query 1 = body:(a OR NOT b) > > This is parsed as: (body:a) -(body:b) and finds 96,620 hits > > Query 2 = body:(a OR (*:* AND NOT b)) > > This is parsed as: (body:a) (+*:* -(body:b)) and finds 149,438 hits > > Query 3 = body:(a AND NOT b) > > This is parsed as: +(body:a) -(body:b) and finds 96,620 hits > > Query 4 = body:(a AND (*:* AND NOT b)) > > This is parsed as: +(body:a) +(+*:* -(body:b)) and finds the same 96,620 hits > > Does anyone know the nuances when working with the NOT operator in > terms of why query 1 and query 2 return different hits whereas query 3 and > query 4 return the same? Is there a correct usage when you want to use NOT > with AND/OR? > > Thanks, > Ian --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org