看,灰机...

子聚合全局排序

Elasticsearch | 作者 alivinliu | 发布于2018年12月03日 | 阅读数:2586

es可不可以实现子聚合的全局排序?
 例如: 
姓名 性别
tom 男
jack 女
jack 女
tom 女
tom 女
 
正常聚合:
{
"key": "tom",
"doc_count": 3,
"s1": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "女",
"doc_count": 2
},
{
"key": "男",
"doc_count": 1
}
]
}
}
,
{
"key": "jack",
"doc_count": 2,
"s1": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "女",
"doc_count": 2
}
]
}
}
期望得到下面结果(即子聚合全局排序)
{
"key": "女",
"doc_count": 2
},
{
"key": "女",
"doc_count": 2
},
{
"key": "男",
"doc_count": 1
}



已邀请:

doctor

赞同来自:

你的顺序是order by name,gender
换成order by gender,name即可实现

zz_hello

赞同来自:

桶聚合就是分桶进行聚合的呀,目前还不能打破桶之间分隔,按照子聚合的情况排序吧

要回复问题请先登录注册