php - 如何按热门字段(文本字段)对聚合进行排序?或者是否有可能按文本字段对聚合进行排序(不使用_term)
问题描述
如标题所示,我在按文本字段对 Elasticsearch 聚合进行排序时遇到问题。有没有可能做到这一点?使用热门歌曲或类似的东西?现在我正在使用术语聚合,我可以使用 _term 按聚合字段排序,但我需要按不同字段对这些聚合进行排序。我知道如何处理具有数值的字段。例如使用最大值、最小值、总和等。
如果我能这样做(但我不能),那就太好了:
"aggs": {
"Variants": {
"terms": {
"field": "variant",
"order": {
"top_Song_hits": "asc"
}
},
"aggs": {
"top_Song_hits": {
"sum": {
"name": {
"order": "desc"
}
}
}
}
}
}
}
或像这样:
{
"aggs": {
"Variants": {
"terms": {
"field": "variant",
"order": {
"name_agg": "asc"
}
},
"aggs": {
"name_agg": {
"terms": {
"field": "name"
}
}
}
}
}
}
或者
{
"aggs": {
"Variants": {
"terms": {
"field": "variant",
"order": {
"details": "asc"
}
},
"aggs": {
"details": {
"top_hits": {
"size": 1,
"_source": {
"include": ["name"]
}
}
}
}
}
}
}
在最后一种情况下我得到错误:
"reason": "Invalid aggregation order path [details]. Buckets can only be sorted on a sub-aggregator path that is built out of zero or more single-bucket aggregations within the path and a final single-bucket or a metrics aggregation at the path end."
解决方案
推荐阅读
- ionic-framework - Ionic 中 Angular 属性和自定义 CSS 属性之间的区别
- delphi - 使用 Lua 脚本向 Delphi 应用程序发送命令
- jwt - DocuSign:在 JWT 令牌中设置过期 - 始终获取一小时过期的访问令牌
- fluentvalidation - 如果对第一个字段的多次验证失败,则停止所有进一步的验证
- java - 如何将日期类型参数作为字符串放入 GET 请求中?格式“yyyy-MM-dd”
- python - apt-get install python3-numpy 没有在python3上安装numpy,而是在python2.7上安装
- angular - 如果内容更多,网格单元格不会拉伸
- php - 在表格中的行和列上拆分 DIV
- android - 在 RecyclerView 中拦截触摸事件,同时忽略内部的 EditText
- python - 在后台运行并行函数的 pyqt5 应用程序