For my requirements, I need to have a filter like below:
{
    "filter": {
        "bool": {
          "must": [
            {
              "bool": {
                "should": [
                  {
                    "term": {
                      "field1": "value1x"
                    }
                  }
                ]
              }
            },
            {
              "bool": {
                "should": [
                  {
                    "term": {
                      "field2": "value2x"
                    }
                  }
                ]
              }
            }
          ]
        }
      }

This is a simplified example. There can be multiple values for the fields 
field1 and/or field2 and hence the inner should filter. I know for a fact 
that the should filter for field2 will usually match much less documents 
than the should filter for field1. After reading this 
<http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_filter_order.html>,
 
it is clear that had I used field1 and field2 directly under the same must 
filter, I should have specified field2 before field1. 

Ask:
1. Does the filter ordering theory hold in general for nested filters like 
in my case? Will I gain in performance if I put the should filter for 
field2 before the should filter for field1? Let's assume that these filters 
are not cached.
2. Does the reverse of the filter ordering theory hold for should filters - 
that filters matching most documents should appear before filters matching 
less documents in a should filter?
3. Does this same theory hold for and/or filters just like it holds for 
must/should filters?
4. Just for my information, for this theory to work, the filters must be 
"evaluated" in a sequence and not in parallel. Correct?

-- 
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/84829783-d67c-464a-9f19-f6aa5309136f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to