Why? Becuase of how the solr/lucene query parser parses?
It parses into seperate tokens/phrases, and then marks each unit as
mandatory or optional. The operator's joining the tokens/phrases are
used to determine if a unit is mandatory or optional.
Since your defaultOperator="AND"....
term1 term2 OR X
is the same as:
term1 AND term2 OR X
because it used the defaultOperator in between term1 and term2, since no
explicit operator was provided.
Then we get to the one you specifically did add the AND in. I guess that
it basically groups left-to-right. So:
term1 AND term2 OR X OR Y
is the same as:
term1 AND (term2 OR (X OR Y))
But I guess you already figured this all out, yeah?
On 5/16/2011 9:24 AM, Dmitry Kan wrote:
Dear list,
Might have missed it from the literature and the list, sorry if so, but:
SOLR 1.4.1
<solrQueryParser defaultOperator="AND"/>
Consider the query:
term1 term2 OR "term1 term2" OR "term1 term3"
Problem: The query produces a hit containing only term1.
Solution: Modified query, grouping with parenthesis
(term1 term2) OR "term1 term2" OR "term1 term3"
produces hits with both term1 and term2 present and other hits that are hit
by OR'ed clauses.
Problem 1. Another modified query, AND instead of parenthesis:
term1 AND term2 OR "term1 term2" OR "term1 term3"
produces same results as the original query and same debug output.
Why is that?