Elasticsearch scoring and filter context

We are working on building a internal query language that converts to ES7 query. I'd like to know what are the implications of generating the following kinds of queries in ES

#1.1

{
  "query": {
    "bool": {
      "must": [
        ...
      ],
      "filter": [
        ...
      ]
    }
  }
}

#1.2
{
  "query": {
    "bool": {
      "filter": {
        "must": [
        ...
        ],
        "filter": [
          ...
        ]
      }
    }
  }
}

Is ES smart enough to not score the must clause in 1.2 because it is in filter context?

EDIT:

I ran a few experiment with 1.1 and 1.2 and 1.2 was a tad bit slower! I actually expected 1.1 to be slower because of scoring!

We do see a lot of cache miss count. We are using the default cache settings. misses are around 400k whereas hits are around 30-40k

Surprisingly

{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "customer(keyword_field)": "big_customer"
          }
        }
      ]
    }
  }
}

is faster than (10 times .. 140ms vs 11ms)

{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "customer(keyword_field)": "big_customer"
          }
        }
      ]
    }
  }
}

^^ for this, when i added sorting, they both slowed down and were roughly performing the same

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.