At a higher level, Elasticsearch supports four types of aggregation:
- Bucket aggregation: This can be used to group or create buckets. Buckets can be created based on an existing field, custom filters, ranges, and so on
- Metric aggregation: This can be used to calculate a metric, such as a count, sum, average, and so on
- Pipeline aggregation: This can be used to chain aggregations. The output of other aggregations can be the input for a pipeline aggregation
- Matrix aggregation: This can be used to calculate statistics over a set of fields
In this section, we will discuss bucket and metric aggregations. Pipeline and matrix aggregations are still experimental and out of the scope of this book.