Operands priorities in Elasticsearch query

Hi,
I am researching the Elasticsearch engine. I would like to know which operand takes precedence on which operands. The only reference I was able to find is:
NOT takes precedence over AND, which takes precedence over OR.
(https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html)

I need to know where is the Proximity operand falls in?
Anyone can help? If there's any place this is documented I will be happy to get the URL.

Thanks,
Niv

The proximity search is not a boolean operator so the priority does not apply to this part of the query. Can you provide us with an example of query where the priority is not clear for you ?

Hi,
Thanks for your answer.
I don't have a specific example. I was making a comparison between KQL that engines like FAST use, and Elasticsearch.
For KQL I found this: https://msdn.microsoft.com/en-us/library/hh658228(v=office.12).aspx
As you can see, it prioritize all operators: boolean and non-boolean.

So, I though Elasticsearch will have something similar.

Yes this is because they have an operator named NEAR. For the query_string we don't have a NEAR operator but you can use the slop parameter of the phrase query:

"fox quick"~5 AND brown

In such case the proximity operator is not ambiguous, it should apply to the phrase query only as a filter. With an operator like NEAR, the ambiguity is resolved by the priority of the operators like in:

fox NEAR quick AND brown

Since the query_string query does not implement such operator we don't need priority.

Thank you very much for this clear answer.
It really helps.

Hi,
One more question:
can I write one of the following queries: “fox quick or brown”~4, or “fox (quick or brown)”~4
so the "or" is calculated before the "proximity"?

No you can't. This is a phrase query and the "or" inside the quote is treated as a normal word.
Though you can achieve what you asked with a span query:
https://www.elastic.co/guide/en/elasticsearch/reference/current/span-queries.html

 "span_near": {
      "clauses": [
         {
            "span_term": {
               "field": "fox"
            }
         },
         {
            "span_or": {
               "clauses": [
                  {
                     "span_term": {
                        "field": "quick"
                     }
                  },
                  {
                     "span_term": {
                        "field": "brown"
                     }
                  }
               ]
            }
         }
      ],
      "slop": 5,
      "in_order": true,
      "collect_payloads": false
   }