I'm using Elasticsearch (version 2.3) to search in an index with several document types. I want to limit the number of results to the top X search hits for each document type. How can that be achieved?
The query is very plain and simple:
{
"sort": [
{
"_type": {
"order": "asc"
}
}
],
"query": {
"query_string": {
"query": "[some search query here]"
}
}
}
I found the answer at https://stackoverflow.com/a/27720049/467650 , but it seems like the syntax may have changed since version 1.4.0 as I'm only getting the following error message:
"reason": {
"type": "search_parse_exception",
"reason": "Found two aggregation type definitions in [types]: [terms] and [hits]",
"line": 1,
"col": 44
}