0

Does wrapping single Elasticsearch queries in bool must queries change search results, or are the following two queries identical (both in terms of how elasticsearch processes them and what the outcome is)?

single query_string query (no bool query as wrapper):

POST _search
{
  "query": {
    "query_string" : { "query" : "My query string" }
}}

bool query that wrapps a single query_string query:

POST _search
{
  "query": {
    "bool" : {
      "must" : {
        "query_string" : { "query" : "My query string" }
}}}}
gustavz
  • 2,964
  • 3
  • 25
  • 47

1 Answers1

1

Both are exactly semantically the same and will produce the same results.

It's worth noting, though, that a bool query only makes sense if there are more than one clause, otherwise it's useless to specify it.

Val
  • 207,596
  • 13
  • 358
  • 360
  • thanks. Yes you are right, but my program automatically adds multiple must clauses to the bool query and i wanted to be sure that a single must clause behaves identical to a single query without bool wrapper. – gustavz Mar 05 '21 at 12:56