You can do it with the following query. The idea is to show for each parent_uuid bucket the first top hit with the minimum id value and to sort the parent_uuid buckets according the smallest id value as well using a min sub-aggregation.{ "aggregations": { "toBeOrdered": { "terms": { "field": "parent_uuid", "size": 1000000, "order": { "topSort": "desc" } }, "aggregations": { "topAnswer": { "top_hits": { "size": 1, "sort": { "b": "desc" } } }, "topSort": { "max": { "field": "id" } } } } }}尝试一下,并报告是否适合您.Try it out and report if this works out for you. 这篇关于Elasticsearch Ordering术语聚合在最热门字段子聚合之后的存储桶中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-14 23:49