Q:

Get 10 best Results from ElasticSearch by domain

I have five different Domains in ElasticSearch, which are indexed and should be used for a fulltext search.
If I do a GET request like 
GET endpoint_to_my_elastic_search/*/_search?q=test

I get the result ordered by _score. So far so good, but I want to have a result which shows me the 10 best hits (by score) of every domain. I tried it this way:
GET endpoint_to_my_elastic_search/domain1/_search?q=test&size=10
GET endpoint_to_my_elastic_search/domain2/_search?q=test&size=10
GET endpoint_to_my_elastic_search/domain3/_search?q=test&size=10
GET endpoint_to_my_elastic_search/domain4/_search?q=test&size=10
GET endpoint_to_my_elastic_search/domain5/_search?q=test&size=10

Nice - it works. Now I have 10 best results from every domain. But the number of domains will increase in the future to 10 or 20. So I have to send 20 request to my ElasticSearch... smells like bad performance ;-)
Is there a way to tell ElasticSearch to give me best 10 Results from every requested Domain? 

A:

I answered a similar question few days back - suggestion is to use top_hits aggs..
Update: _index is a meta field, so you may be able to query across multiple indices using wildcard or an alias and use that field for agg:
curl -XPOST localhost:9200/index-*/_search?pretty -d '
{
  "aggs": {
    "top_indices": {
      "terms": {
        "field": "_index"
      },
      "aggs": {
        "top_docs": {
          "top_hits": {}
        }
      }
    }
  }
}'

