Expression Evaluation

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Expression Evaluation

Thomas L. Redman
I suspect nobody wants to broach this topic, this has to have come up before, but I can not find an authoritative answer. How does the Standard Query Parser evaluate boolean expressions? I have three fields, content, status and source_name. The expression

content:bement AND status:relevant

yields 111 documents. The expression

source_name:Web

yields 78050168 documents. However, the expression

content:bement AND status:relevant OR source_name:Web

yields 111 documents. Can anybody describe the order of operation, operator priorities used in evaluating the above expression? It looks to me as if it takes the intersection of content:bement and status:relevant, then limits successive set operators to that set. Is that true? So any additional “OR” expressions will have no effect?
Reply | Threaded
Open this post in threaded view
|

Re: Expression Evaluation

Erick Erickson
The short form is that the query parsers do not implement Boolean
logic by design. The boolean operators are approximated more or less
accurately by using parentheses. So try:

(content:bement AND status:relevant) OR source_name:Web

or, using the "real" syntax, something like:

+content:bement +status:relevant  source_name:Web

Also use &debug=query to see exactly what the resulting parsed query
is, but be aware you need to understand the +- etc notation.

Here's a pretty extensive treatment of the issue:
https://lucidworks.com/2011/12/28/why-not-and-or-and-not/

Best,
Erick
On Thu, Dec 6, 2018 at 10:02 AM Thomas L. Redman <[hidden email]> wrote:

>
> I suspect nobody wants to broach this topic, this has to have come up before, but I can not find an authoritative answer. How does the Standard Query Parser evaluate boolean expressions? I have three fields, content, status and source_name. The expression
>
> content:bement AND status:relevant
>
> yields 111 documents. The expression
>
> source_name:Web
>
> yields 78050168 documents. However, the expression
>
> content:bement AND status:relevant OR source_name:Web
>
> yields 111 documents. Can anybody describe the order of operation, operator priorities used in evaluating the above expression? It looks to me as if it takes the intersection of content:bement and status:relevant, then limits successive set operators to that set. Is that true? So any additional “OR” expressions will have no effect?