【发布时间】:2015-12-18 00:56:03
【问题描述】:
Elasticsearch 文档指出 The top_hits aggregation returns regular search hits, because of this many per hit features can be supported 至关重要的是,该列表包括 Named filters and queries
但尝试添加任何过滤器或查询会抛出 SearchParseException: Unknown key for a START_OBJECT
用例:我有包含嵌套 cmets 列表的项目
items{id} -> cmets {日期,评级}
我想在上周获得每个项目的最高评价。
{
"query": {
"match_all": {}
},
"aggs": {
"items": {
"terms": {
"field": "id",
"size": 10
},
"aggs": {
"comment": {
"nested": {
"path": "comments"
},
"aggs": {
"top_comment": {
"top_hits": {
"size": 1,
//need filter here to select only comments of last week
"sort": {
"comments.rating": {
"order": "desc"
}
}
}
}
}
}
}
}
}
}
那么是文档有误,还是有什么办法可以添加过滤器?
【问题讨论】:
-
您能否发布您的查询以及一些示例文档和所需的输出?
-
@ChintanShah25 更新了问题
标签: elasticsearch