Wanted to combine two different result set in one query

Hi There,

I have requirement where I need to combine two different result based on different filter criteria for example one query is filtering records based on some true & false indicator and then other query is filtering record on country location. After combining both the record I want to combine both result and then select only do the sizing (including both the records I want only 10 or 20), Can someone help me here -

{
  "size": 20,
  "sort": [
    {
      "virtualOnly": {
        "order": "desc"
      }
    }
  ],
  "query": {
    "bool": {
      "must": [
        {
          "multi_match": {
            "query": "true",
            "operator": "and",
            "fields": [
              "virtualOnly"
            ]
          }
        }
      ],
      "should": [
        {"match": {
          "address.country.code": "US"
        }}
      ]
    }
  }
}

if you put two queries in a boolean query should clause this will act as an OR.

You cannot select the size based on some search criteria - which is how I understood your question, but maybe I got it wrong.

Also have a look at the multisearch API.
May be that could work for you.

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