Consider the following queries
"-a:d +b:2 +(-c:[* TO *])" this query is not returning any result.
"-a:d +b:2 -c:[* TO *]" whereas this query returns results.
For #1,
It evaluates c then a then b.
For #2
It evaluates a, then b then c.
Ideally, it is same. What's the difference in this?
Kindly help. Thanks in advance. It is standard query parser.
Think of each part of the query in Solr as representing a set of documents. A document is either part of the set or not, and you then perform operations between these sets as part of your query.
ANDmeans that "documents that are in both these sets should be included" (an intersection),ORmeans "documents that are in either of these sets should be included" (a union) andNOTor-means "subtract this set from the other set".Given your first query, it gets parsed as:
If we ignore that Solr sometimes prefixes the set of all matching documents to your query so that you start with a set representing "all documents" instead of "no documents", and assume that we always start with an empty set, we can see why we get no documents:
If we change the last step to include all documents first (
*:*):