简体   繁体   中英

Single bool must queries in Elasticsearch

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" }
}}}}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM