You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Rublex <ru...@hotmail.com> on 2012/06/27 23:59:22 UTC

Query Logic Question

Hi,

Can someone explain to me please why these two queries return different
results:

1. -PaymentType:Finance AND -PaymentType:Lease AND -PaymentType:Cash *(700
results)*

2. (-PaymentType:Finance AND -PaymentType:Lease) AND -PaymentType:Cash *(0
results)*

Logically the two above queries should be return the same results no?

Thank you

--
View this message in context: http://lucene.472066.n3.nabble.com/Query-Logic-Question-tp3991689.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Query Logic Question

Posted by Li Li <fa...@gmail.com>.
I think they are logically the same. but 1 may be a little bit faster than 2

On Thu, Jun 28, 2012 at 5:59 AM, Rublex <ru...@hotmail.com> wrote:
> Hi,
>
> Can someone explain to me please why these two queries return different
> results:
>
> 1. -PaymentType:Finance AND -PaymentType:Lease AND -PaymentType:Cash *(700
> results)*
>
> 2. (-PaymentType:Finance AND -PaymentType:Lease) AND -PaymentType:Cash *(0
> results)*
>
> Logically the two above queries should be return the same results no?
>
> Thank you
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Query-Logic-Question-tp3991689.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: Query Logic Question

Posted by Erick Erickson <er...@gmail.com>.
I think you're assuming that this is Boolean logic. It's not, see:
http://www.lucidimagination.com/blog/2011/12/28/why-not-and-or-and-not/

Best
Erick

On Thu, Jun 28, 2012 at 9:27 AM, Rublex <ru...@hotmail.com> wrote:
> Jack,
>
> Thank you the *:* solutions seems to work.
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Query-Logic-Question-tp3991689p3991881.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: Query Logic Question

Posted by Rublex <ru...@hotmail.com>.
Jack,

Thank you the *:* solutions seems to work.

--
View this message in context: http://lucene.472066.n3.nabble.com/Query-Logic-Question-tp3991689p3991881.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Query Logic Question

Posted by Jack Krupansky <ja...@basetechnology.com>.
It should work properly with the edismax query parser. The traditional 
lucene query parser is not smart enough about the fact that the Lucene 
BooleanQuery can't properly handle queries with only negative clauses.

Put *:* in front of all your negative terms and you will get similar 
results. edismax does that automatically.

(*:* -PaymentType:Finance AND *:* -PaymentType:Lease) AND 
*:* -PaymentType:Cash

-- Jack Krupansky

-----Original Message----- 
From: Rublex
Sent: Wednesday, June 27, 2012 4:59 PM
To: solr-user@lucene.apache.org
Subject: Query Logic Question

Hi,

Can someone explain to me please why these two queries return different
results:

1. -PaymentType:Finance AND -PaymentType:Lease AND -PaymentType:Cash *(700
results)*

2. (-PaymentType:Finance AND -PaymentType:Lease) AND -PaymentType:Cash *(0
results)*

Logically the two above queries should be return the same results no?

Thank you

--
View this message in context: 
http://lucene.472066.n3.nabble.com/Query-Logic-Question-tp3991689.html
Sent from the Solr - User mailing list archive at Nabble.com.