gpt4 book ai didi

elasticsearch - 未将过滤器应用于聚合

转载 作者:行者123 更新时间:2023-12-03 02:28:11 25 4
gpt4 key购买 nike

我正在尝试获取特定用户销售的产品的账单,但似乎该查询未应用于总和。
有人可以帮我吗?

{
"query": {
"bool": {
"filter": [
{ "term": { "seller": 1 } },
{"term": { "product": 2 } }

]
}
},
"size": 0,
"aggs": {
"product": {
"terms": {
"field": "product"
},
"aggregations": {
"billing": {
"sum": {
"field": "price"
}
},
"aggregation": {
"bucket_sort": {
"sort": [
{
"billing": {
"order": "desc"
}
}
]
}
}
}
}
}
}

最佳答案

尝试将现有的聚合嵌套在“卖方”的另一个术语聚合中。

{
"query": {
"bool": {
"filter": [
{
"term": {
"seller": 1
}
},
{
"term": {
"product": 2
}
}
]
}
},
"size": 0,
"aggs": {
"seller": {
"terms": {
"field": "seller",
"size": 1
},
"aggs": {
"product": {
"terms": {
"field": "product",
"size": 1
},
"aggregations": {
"billing": {
"sum": {
"field": "price"
}
},
"aggregation": {
"bucket_sort": {
"sort": [
{
"billing": {
"order": "desc"
}
}
]
}
}
}
}
}
}
}
}

关于elasticsearch - 未将过滤器应用于聚合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60602487/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com