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
1) 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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/01695d3b-3200-4785-876b-bb960cc242dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.