Search Multiple indices in a cluster

I have two different indices(index-1, index-2) in a cluster with the same schema. I know I can query the two indices together in a single query, so if I set in the query "size":1000 elastic search will return 1000 results from each of the indices, sort the 2000 results according to the "_score" and return back the top 1000 documents.

However I am curious to know if there is a way to force elastic search to pick only maybe 10 documents from index-1 and the rest of the 990 documents from index-2? I am using ElasticSearch 7.1

This is the query I am using.

GET /index-1,index-2/_search/
{
  "query": {
    "multi_match": {
      "query": "My query",
      "fields": [
        "field_1",
        "field_2"
      ]
    }
  },
  "size": 1000
}

You can do that by sending 2 separate queries at once in the same request using the multi search API. You can as far as I know not control that way if it is in a single query.

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