I believe I understand the problem now.
- ES applies operators immediately to the left and right operand
- ES does not virtually parenthesize groups after evaluating a higher
precedence operator
Thus, with a default operator of AND.
Z B C OR D E F is interpreted as +Z + B C D +E +F
My expectation would have been interpreted as Z AND B AND C OR D AND E AND
F to evalulate to (+Z + B +C) OR (+D +E + F)
Does ES intend to fix this to more match the latter expectation? It seems
the only mitigation right now would be to:
(Z B C) OR (D E F)
On Friday, May 9, 2014 10:21:49 AM UTC-7, Erich Lin wrote:
Thank you Binh. That validate API with explain is quite helpful. The
feature seems a bit confusing because the API for query_string states that
the precedence order of logical operators follow:
AND first, then OR.Thus, when I see 'sofa OR rugs AND red', my brain would translate that
into
- Do the highest precedence operator : AND -> sofa OR (rugs AND red)
Could you explain why this would be a feature and how it does not conflict
with the API's definition of precedence?Erich
On Friday, May 9, 2014 7:18:02 AM UTC-7, Binh Ly wrote:
It's a "feature" of the query_string. What's happening is this query:
sofa OR rugs AND red
Actually means "rugs" and "red" must be there (always) to match. And if a
document is a match (i.e. it contains both rugs and red) and it contains
sofa also, then boost that document up some more ahead of the others.This query:
sofa OR (rugs AND red)
Actually means either "sofa" is there, or ("rugs" and "red") is there to be a match. This is what you expect as normal boolean logic.
The easiest way to see and understand whats happening is to use the _validate API like this:
curl -XPOST "http://localhost:9200/f/_validate/query?explain&pretty" -d '
{
"query": {
"query_string": {
"query": "sofa OR rugs AND red",
"default_operator": "AND"
}
}
}'If you _validate/explain the other query, you will understand how it is "interpreted".
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/07152b76-a588-4305-a3f3-78738e92717a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.