栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

计算子聚合返回的存储桶

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

计算子聚合返回的存储桶

您可以利用“
统计数据桶聚合”来获取存储桶数。

以下是查询的方式。

汇总查询:

POST visitor_carts/_search{  "size": 0,  "aggs": {    "visitors": {      "terms": {        "field" : "visitor_id"      },      "aggs": {        "one_purchase": {          "bucket_selector": { "buckets_path": {   "nb_purchases": "_count" }, "script": "params.nb_purchases == 3"          }        }      }    },    "mybucketcount":{      "stats_bucket": {        "buckets_path":"visitors._count"      }    }  }}

汇总结果:

{  "took": 1,  "timed_out": false,  "_shards": {    "total": 5,    "successful": 5,    "failed": 0  },  "hits": {    "total": 8,    "max_score": 0,    "hits": []  },  "aggregations": {    "visitors": {      "doc_count_error_upper_bound": 0,      "sum_other_doc_count": 0,      "buckets": [        {          "key": "2",          "doc_count": 3        },        {          "key": "3",          "doc_count": 3        }      ]    },    "mybucketcount": {      "count": 2,   <---- This is the count you are looking for      "min": 3,      "max": 3,      "avg": 3,      "sum": 6    }  }}

让我知道是否有帮助!



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/409512.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号