Since there are no parentheses, the terms and operators are all at the save level and the "OR" is essentially a redundant operator and ignored, so:

q=name:memory OR -name:encoded

is treated as:

q=name:memory -name:encoded

When what you probably want is:

q=name:memory OR (-name:encoded)

BUT... a bug/deficiency prevents Solr from handling pure-negative sub-queries properly, so you have to add a "*:*":

q=name:memory OR (*:* -name:encoded)

So that reads "... or any documents that do not contain encoded in the name field", which is equivalent to "... or all documents except those that have encoded in the name field".

-- Jack Krupansky

-----Original Message----- From: karanjindal
Sent: Wednesday, July 31, 2013 2:14 AM
To: solr-user@lucene.apache.org
Subject: Negative Query Behaviour in Solr 3.2

Hi All,

I am using solr 3.2 and confused how a particular query is executed.
q=name:memory OR -name:encoded
separately firing q=name:memory gives 3 results
and q=-name:encoded gives 25 results and result sets are disjoint sets.

Since I am doing OR query it should return 28 results, but it is only
returning 3 results same as query (name:memory).

Can anyone explain?

-Karan




--
View this message in context: http://lucene.472066.n3.nabble.com/Negative-Query-Behaviour-in-Solr-3-2-tp4081538.html Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to