我正在使用 Elasticsearch(2.3 版)在具有多种文档类型的索引中进行搜索。我想将结果数限制为每种文档类型的前 X 个搜索命中。怎样才能做到这一点?
查询非常简单明了:
{
"sort": [
{
"_type": {
"order": "asc"
}
}
],
"query": {
"query_string": {
"query": "[some search query here]"
}
}
}
我在https://stackoverflow.com/a/27720049/467650找到了答案,但似乎自 1.4.0 版以来语法可能已经改变,因为我只收到以下错误消息:
"reason": {
"type": "search_parse_exception",
"reason": "Found two aggregation type definitions in [types]: [terms] and [hits]",
"line": 1,
"col": 44
}