Re: boolean versus non-boolean search
On 05/16/2011 09: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 Consider the query: term1 term2 OR "term1 term2" OR "term1 term3" I think what's happening is that your query gets rewritten into something like: +term1 + (term2? "term1 term2"? term3?) where in my notation ? means is "optional", and "+" means required. So any document would match the second clause -Mike
Re: boolean versus non-boolean search
Hi Jonathan, Well, I clearly understand, why 'term1 term2 OR ...' gives exactly same results as 'term1 AND term2 OR ...', but what I do not get is, why grouping with parentheses is required to have both term1 and term2 in the same hit even though AND is the default operator and space between terms is expected to be treated as AND. Dmitry On Mon, May 16, 2011 at 6:33 PM, Jonathan Rochkind wrote: > 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 >> >> >> >> 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? >> >> -- Regards, Dmitry Kan
Re: boolean versus non-boolean search
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 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?
boolean versus non-boolean search
Dear list, Might have missed it from the literature and the list, sorry if so, but: SOLR 1.4.1 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? -- Regards, Dmitry Kan