如何解决我如何使用 top_hits 中的字段对顶级存储桶进行排序
我一直在尝试使用 top_hits 字段对 actionee_id 存储桶进行排序,但未能实现
{
"size": 0,"aggs": {
"actionee_id": {
"terms": {
"field": "actionee_id","size": 50
},"aggs": {
"player": {
"top_hits": {
"sort": {
"created_at": {
"order": "desc"
}
},"_source": {
"include": [
"actionee"
]
},"size": 1
}
},"pagination": {
"bucket_sort": {
"sort": [
{
"debit>amount_total.value": {
"order": "desc"
}
}
],"size": 5,"from": 0
}
},"debit": {
"filter": {
"term": {
"transaction_type": "debit"
}
},"aggs": {
"amount_total": {
"sum": {
"field": "amount"
}
}
}
}
}
}
}
}
以下是我在 top_hits 中收到的输出
"player" : {
"hits" : {
"total" : {
"value" : 8,"relation" : "eq"
},"max_score" : null,"hits" : [
{
"_index" : "transactions_development_20210305080754941","_type" : "_doc","_id" : "421","_score" : null,"_source" : {
"actionee" : {
"parent_name" : "Stefany","country_code" : null,"parent_chain_ids" : [
6,5
],"wallet" : {
"balance" : 20000.0,"currency" : "EUR"
},"user_name" : "Filiberto","parent_id" : 6,"last_name" : null,"active" : true,"creation_date" : "2021-02-12T06:23:50.702Z","type" : "User","first_name" : null,"email" : "stanford@runolfsson.co"
}
},"sort" : [
1614677210329
]
}
]
}
}
我也尝试先在 actionee_id 上聚合,然后在 actionee.user_name 上聚合,但是这样,我实现了bucket下的bucket,然后无法使用内部bucket的键对外部bucket进行排序
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。