Ace McCloud
Ace McCloud

Reputation: 711

Difference between simple query containing query_string, and bool query in Elastic search

I wrote the following query to fetch records from an Elastic Search cluster.

{
      "query" : {
            "query_string" : {
              "query" : "One Record"
            }
      },
      "explain" : true
}

However, later I found out that the following query also produces the same results.

{
  "query" : {
    "bool" : {
      "should" : {
        "query_string" : {
          "query" : "One Record"
        }
      }
    }
  },
  "explain" : true
}

Will both the above queries always produce the same results?

Upvotes: 0

Views: 105

Answers (1)

Ankur Goel
Ankur Goel

Reputation: 206

A bool query merely combines other types of queries and adds over the scores , hence the above two queries will always give the same result.

Upvotes: 1

Related Questions