我想使用bucket_selector过滤聚合结果,但是我想在top_hits结果上使用它。可能吗?
GET new-transactions-2/_search
{
"size": 0,
"aggs": {
"aggs_name": {
"nested": {
"path": "items"
},
"aggs": {
"products": {
"terms": {
"field": "items.product_id",
"size": 10
},
"aggs": {
"sum_amount": {
"sum": {
"field": "items.amount"
}
},
"bucketSelector1": {
"bucket_selector": {
"buckets_path": {
"x" : "sum_amount"
},
"script": "params.x > 40000"
}
},
"additionalFields": {
"top_hits": {
"_source": {"includes": ["items.amount", "items.title"]},
"size": 1
}
}
}
}
}
}
}
}
这是我想要实现的虚构代码。
"bucketSelector2": {
"bucket_selector": {
"buckets_path": {
"x" : "additionalFields"
},
"script": "params.additionalFields.items.title.contains('Ayam')"
}
}
运行此请求时收到警告。据说
buckets_path必须引用数字值或单个值数字度量聚合,得到:聚合[additionalFields]处的[InternalTopHits]
我很好奇是否还有另一种方法可以实现这种过滤器,请帮忙。