SOLR ignores 'NOT' clause in query

Go To StackoverFlow.com

2

We have a simple domain where

FirstName_s:"Bob"

returns 40 documents, and

-Department_t:"Ninjas"

returns all of the documents (we don't have a ninja department).

We expected the query

(FirstName_s:"Bob") OR (-Department_t:"Ninjas")

to return all documents, however it only returned the original 40 documents.

We have experimented with a couple of different orderings, tried using 'NOT' instead of '-' all to no avail.

Is this expected behavior? Perhaps more importantly, how do we get the behavior we expect?

2012-04-04 18:26
by Tom
Thanks to @jarosławgomułka, I've openned this ticketTom 2012-04-04 19:06


0

I stumbled upon https://issues.apache.org/jira/browse/SOLR-2209 so maybe parentheses are causing error. Does this work ?

FirstName_s:"Bob" OR -Department_t:"Ninjas"

Does rewritting the query in a way, that it won't contain OR (using De_Morgan's law) helping ?

-(-FirstName_s:"Bob" AND Department_t:"Ninjas")
2012-04-04 18:42
by Jarosław Gomułka
Removing parens didn't work, but refactoring with De Morgans did. Thanks! I'll file a bug with Solr, I don't think we should have to use de Morgans on query generation - Tom 2012-04-04 19:00


0

This turned out to be an issue with multivalued fields and the way they behave with not.

We had to modify all of our not queries for multivalued fields to

(*:* -department_t:"Ninjas")
2012-04-05 15:19
by Tom
Ads