[英]Elasticsearch term aggregation with range doc count
I want to aggregate a field and return only those buckets in which doc count is within 10 to 20 for eg 我想汇总一个字段,仅返回文档计数在10到20以内的那些存储桶,例如
So far from documentation it says that we can provide min_doc_count
parameter. 到目前为止,它还说我们可以提供
min_doc_count
参数。
Is there any way we can provide max_doc_count
also so i only get required buckets ? 有什么办法我们也可以提供
max_doc_count
这样我只能获得所需的存储桶?
Thanks 谢谢
you can use the following query to filter the buckets using bucket_selector aggregation. 您可以使用以下查询通过bucket_selector聚合来过滤存储桶。 You can take a deep look at pipeline aggregations and buckets paths here .
您可以在此处深入了解管道聚合和存储桶路径。
In the following example i am aggregating the document on product.name field where product is of type object for me. 在以下示例中,我正在product.name字段上汇总文档,其中product对于我来说是object类型。
{
"size": 0,
"aggs": {
"values": {
"terms": {
"field": "product.name.raw",
"size": 10
},
"aggs": {
"final_filter": {
"bucket_selector": {
"buckets_path": {
"values": "_count"
},
"script": "params.values > 10 && params.values < 20"
}
}
}
}
}
}
Hope this helps Thanks 希望这对您有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.