gpt4 book ai didi

json - 如何过滤嵌套聚合

转载 作者:行者123 更新时间:2023-12-03 00:23:24 25 4
gpt4 key购买 nike

我正在尝试对不同的嵌套聚合应用不同的过滤器。有没有办法做到这一点?

"filter": {
"nested": {
"path": "hierarchy.productGroup",
"filter": {
"terms": {
"hierarchy.productGroup.name": ["iPhone"]
}
}
}
},
"aggs": {
"category": {
"nested": {
"path": "hierarchy.productGroup"
},
"aggs": {
"category": {
"terms": {
"field": "hierarchy.productGroup.name"
}
}
}
},
"color": {
"filter": {
"nested": {
"path": "hierarchy.productGroup",
"filter": {
"terms": {
"hierarchy.productGroup.name": ["iPhone"]
}
}
}
},
"nested": {
"path": "specs.measurementsProduct.colorName"
},
"aggs": {

"color": {
"terms": {
"field": "specs.measurementsProduct.colorName.name"
}
}
}
}
}

当我运行此查询时,出现以下错误:
Error: Parse Failure [Found two aggregation type definitions in [color]: [filter] and [nested]]];

我想使我的颜色聚合取决于类别过滤器。

最佳答案

您忘记了以开头的键和以结尾的键。
尝试使用此json:

{
"filter": {
"nested": {
"path": "hierarchy.productGroup",
"filter": {
"terms": {
"hierarchy.productGroup.name": ["iPhone"]
}
}
}
},
"aggs": {
"category": {
"nested": {
"path": "hierarchy.productGroup"
},
"aggs": {
"category": {
"terms": {
"field": "hierarchy.productGroup.name"
}
}
}
},
"color": {
"filter": {
"nested": {
"path": "hierarchy.productGroup",
"filter": {
"terms": {
"hierarchy.productGroup.name": ["iPhone"]
}
}
}
},
"nested": {
"path": "specs.measurementsProduct.colorName"
},
"aggs": {
"color": {
"terms": {
"field": "specs.measurementsProduct.colorName.name"
}
}
}
}
}
}

关于json - 如何过滤嵌套聚合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28585676/

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