0
votes

If you wrap bool query in constant Score Query does it calculate score for internal queries. Is there another easy way to disable scoring?

Hi I have an update so I have a query where no scoring is required, so I wrote it in two forms and did load testing with 10000 documents.

Following are the two structures of query with which I did load testing:

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

And the second one is:

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

What I found was that the first query took almost as double time as the second query. I would like to know why this happened?

Also, do the internal bool queries inside filter in first example run in query context or filter context?

I have read elastic search documentation and cannot find references or details on how it works internally.

Thanks, in advance!!

2

2 Answers

1
votes

Query can have two type of context in elastic search. Query context and filter context. Query context tells how well a document matches the query i.e. it calculates score whereas filter context tells whether a document matches the query and no scoring is done.

To answer your question, if you don't want scoring for bool query simply put it in filter context. More info on query context can be found here

0
votes

Caching is probably why. See the documentation: "Frequently used filters will be cached automatically by Elasticsearch, to speed up performance."

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-filter-context.html