0

I have 2 queries:

GET _search
{
  "query": {
    "constant_score": {
      "filter": {
        "term": {
          "idpays": 250
        }
      }
    }
  }
}

and

GET _search
{
  "query": {
    "constant_score": {
      "filter": {
        "bool": {
          "must": {
            "term": {
              "idpays": 250
            }
          }
        }
      }
    }
  }
}

Theses 2 queries return the same results. Which one has the best performance? The first one or the second one with bool and must?

Regards

1 Answer 1

1

Since Elasticsearch uses lucene under the hood all the queries are rewritten as simpler lucene queries before they are executed. If you use overly complicated queries to do a simple task, it will take Elasticsearch more time to rewrite the query into a simpler one.

add "profile": true at the root of your query to return a detailed analysis of the performance stats of the query and take a look at the rewrite time. The larger the time the more complex the query is. A quick look tells me the second one should be slower but you should analyze the results yourself.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.