Bool Query with multiple term queries inside should OR MultiSearch Queries

I have bool query which is perfectly satisfying my request which is like:

GET product/product/_search?pretty
{
  "query" : {
    "bool": {
      "should": [
        {
          "term": {
            "field1" : "xxxx1"
          }
        },
        {
          "term" : {
            "field2" : "xxxx2"
          }
        },
        {
          "term" : {
            "field1" : "xxxx3"
          }
        }
      ]
    }
  }
}

I am thinking whether this will be faster or multisearch request like shown below.
But in multisearch request I need coagulate all responses if there responses with same document in it.
But in above, for e.g. I am getting 2 documents. This is what I require.
In case of multisearch, I will get 3 documents for each queries out of which two will be same, so I need to coagulate it using set on the key value from document.

My multi search request will be like:

curl -H "Content-Type: application/x-ndjson" -XGET localhost:9200/_msearch --data-binary "@request"

where request is

{"index":"product"}
{"query" : {"term" : {"field1" : "xxxx1"}}}
{"index":"product"}
{"query" : {"term" : {"field2" : "xxxx2"}}}
{"index":"product"}
{"query" : {"term" : {"field1" : "xxxx3"}}}

Bool queries should be reasonably fast. I would go with the first approach because it makes things simpler, especially if there is overlap between the matches of each should clause.

Just asking, are bool queries done in parallel in lucene, because I think its been done at lucene level.
Will it be faster if there is no overlap between matches?
or multisearch will be faster?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.