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?
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")
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")