码迷,mamicode.com
首页 > 其他好文 > 详细

Elasticsearch 学习之子聚集过滤

时间:2019-02-24 23:10:57      阅读:363      评论:0      收藏:0      [点我收藏+]

标签:agg   总数   col   聚合   search   msisdn   arch   ast   sel   

1. 获取子聚合结果总数
{
    "size": 0,
    "aggs": {
        "msisdnAgg": {
            "terms": {
                "field": "msisdn"
            },
            "aggs": {
                "tagAggs": {
                    "terms": {
                        "field": "tags"
                    }
                },
                "sum_of_rul": {
                    "sum_bucket": {
                        "buckets_path": "tagAggs>_count"
                    }
                }
            }
        }
    }
}

2. 获取子聚合结果总数大于指定数

{
    "size": 0,
    "aggs": {
        "msisdnAgg": {
            "terms": {
                "field": "msisdn"
            },
            "aggs": {
                "tagAggs": {
                    "terms": {
                        "field": "tags"
                    }
                },
                "sum_of_rul": {
                    "sum_bucket": {
                        "buckets_path": "tagAggs>_count"
                    }
                },
                "orderNumber_count_filter": {
                    "bucket_selector": {
                        "buckets_path":  {
                            "orderNumberCount": "sum_of_rul"
                        },
                        "script": "orderNumberCount > 2 "
                    }
                }
            }
        }
    }
}

 

Elasticsearch 学习之子聚集过滤

标签:agg   总数   col   聚合   search   msisdn   arch   ast   sel   

原文地址:https://www.cnblogs.com/sunfie/p/10428460.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!