Deprecated: Optional parameter $keys declared before required parameter $cms_id is implicitly treated as a required parameter in /home/www/dev/work/class/blog/CmsKey.php on line 75

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\es::$title is deprecated in /home/www/dev/work/website/lvesu/class/controller/blog/es.php on line 28

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\es::$outlink is deprecated in /home/www/dev/work/website/lvesu/template/blog/cms/es.manual.tpl on line 2

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\es::$status is deprecated in /home/www/dev/work/website/lvesu/template/blog/index.head.php on line 2
桶和指标的组合 | Elasticsearch: 权威指南 | Elastic - 互联网笔记

略微加速

Elasticsearch权威指南 - 互联网笔记

桶和指标的组合 | Elasticsearch: 权威指南 | Elastic

2025-04-19

桶和指标的组合编辑

聚合 是由桶和指标组成的。 聚合可能只有一个桶,可能只有一个指标,或者可能两个都有。也有可能有一些桶嵌套在其他桶里面。例如,我们可以通过所属国家来划分文档(桶),然后计算每个国家的平均薪酬(指标)。

由于桶可以被嵌套,我们可以实现非常多并且非常复杂的聚合:

1.通过国家划分文档(桶)

2.然后通过性别划分每个国家(桶)

3.然后通过年龄区间划分每种性别(桶)

4.最后,为每个年龄区间计算平均薪酬(指标)

最后将告诉你每个 <国家, 性别, 年龄> 组合的平均薪酬。所有的这些都在一个请求内完成并且只遍历一次数据!

官方地址:https://www.elastic.co/guide/cn/elasticsearch/guide/current/_combining_the_two.html

冷却塔厂家 广告
中文GPT4.0无需注册 广告
北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3