Elasticsearch专题精讲—— Aggregations —— Bucket aggregations(桶聚合)

发布时间 2023-06-14 17:41:16作者: 左扬

Aggregations —— Bucket aggregations(桶聚合)

https://www.elastic.co/guide/en/elasticsearch/reference/8.8/search-aggregations-bucket.html#search-aggregations-bucket

Bucket aggregations don’t calculate metrics over fields like the metrics aggregations do, but instead, they create buckets of documents. Each bucket is associated with a criterion (depending on the aggregation type) which determines whether or not a document in the current context "falls" into it. In other words, the buckets effectively define document sets. In addition to the buckets themselves, the bucket aggregations also compute and return the number of documents that "fell into" each bucket.

桶聚合不像度量聚合那样在字段上计算指标,而是创建文档桶。每个桶都和一个标准相关(取决于聚合类型),这个标准决定了当前上下文中的文档是否会“归入”该桶。换言之,桶有效地定义了文档集合。除了桶本身之外,桶聚合还会计算并返回每个桶中文档的数量。