Elasticsearch index search with different limits Elasticsearch index search with different limits elasticsearch elasticsearch

Elasticsearch index search with different limits


What you're asking for seems to be field collapsing or grouping.

There's a long-outstanding ticket for this feature on the Elasticsearch issue tracker: https://github.com/elasticsearch/elasticsearch/issues/256, with the latest update being (from http://www.elasticsearch.com/blog/from-amsterdam-with-love-elasticsearchs-second-company-all-hands/) that while progress is being made, it won't come before after 1.0 has been released:

We again fleshed out what is needed in order to properly support field collapsing in a distributed environment execution, as well as the ability to get inner hits (for nested / parent child cases). We have a good idea on the type of refactoring we need in our search execution infrastructure, and hope to tackle it post 1.0.

Until this feature is added, your best bet is to perform multiple searches and combine their results in the way you want, using the multi search api as suggested by Damien. This means constructing one search request per required group (in your case, setting the index/type for each search) and parsing the sort-of JSON returned.