我只需要用于用户的前20个文档的sum_char2cust和sum_cust2char
GET chatsession/_search
{
"query": {
"bool": {
"filter": [
{
"range": {
"char2cust": {
"gte": 10
}
}
}
]
}
},
"size": 0,
"aggs": {
"uniq_user": {
"terms": {
"field": "user_name",
"size": 99999
},
"aggs": {
"sum_char2cust": {
"sum": {
"field": "char2cust"
}
},
"sum_cust2char": {
"sum": {
"field": "cust2char"
}
}
}
}
}
}
我只需要sum_char2cust和sum_cust2char 独特的用户。我尝试使用top_hit和其他解决方案,但不使用 为我工作。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在查询下应该给您预期的结果
Below query should gives you expected result
为了获得
char2cust
和Cust2Char
字段的总和,对于前20位用户(基于其ID),您需要基于最大聚合结果。尝试以下查询:
In order to get the sum of
char2cust
andcust2char
field, for top 20 users (based on their id), you need to sort the terms aggregation result based on the Max Aggregation result.Try out this below query: