elasticsearch 我们可以在ElasticSearch中的嵌套聚合上应用Bucket选择器聚合吗?
我想在ElasticSearch 2.4中使用管道聚合(Bucket选择器聚合)来嵌套字段聚合。我想做下面类似的事情,但我没有成功。您能否建议我是否可以在嵌套字段中进行管道聚合elasticsearch 我们可以在ElasticSearch中的嵌套聚合上应用Bucket选择器聚合吗?,elasticsearch,lucene,elasticsearch,Lucene,我想在ElasticSearch 2.4中使用管道聚合(Bucket选择器聚合)来嵌套字段聚合。我想做下面类似的事情,但我没有成功。您能否建议我是否可以在嵌套字段中进行管道聚合 { "size": 0, "aggregations": { "totalPaidAmount": { "nested": { "path": "count" }, "aggregations": { "paidAmountTotal"
{
"size": 0,
"aggregations": {
"totalPaidAmount": {
"nested": {
"path": "count"
},
"aggregations": {
"paidAmountTotal": {
"sum": {
"field": "count.totalPaidAmount"
}
},
"paidAmount_filter": {
"bucket_selector": {
"script": {
"inline": "amount > 5000000"
},
"buckets_path": {
"amount": "paidAmountTotal"
}
}
}
}
}
}
}
script
值中缺少params
。因此,paidAmount\u过滤器
应该如下所示:
"bucket_filter": {
"bucket_selector": {
"buckets_path": {
"amount ": "paidAmountTotal"
},
"script": "params.amount > 5000000"
}
}
我找到了查询的解决方案。实际上,bucket选择器聚合应该与嵌套聚合并行,路径应该由“>”引用,如下所示:
{
"size": 0,
"aggregations": {
"amount": {
"terms": {
"field": "countId",
"size": 0
},
"aggregations": {
"totalPaidAmount": {
"nested": {
"path": "count"
},
"aggregations": {
"paidAmountTotal": {
"sum": {
"field": "count.totalPaidAmount"
}
}
}
},
"paidAmount_filter": {
"bucket_selector": {
"script": {
"inline": "amount > 1000"
},
"buckets_path": {
"amount": "totalPaidAmount>paidAmountTotal"
}
}
}
}
}
}
}