与标题中一样,我在按文本字段对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."
答案 0 :(得分:0)