Metric aggregations work with numerical data, computing one or more aggregate metrics within the given context. The context can be a query, filter, or no query, to include the whole index/type. Metric aggregations can also be nested inside other bucket aggregations. In this case, these metrics will be computed for each bucket in the bucket aggregations.
We will start with simple metric aggregations, without nesting them inside bucket aggregations. When we learn about bucket aggregations later in this chapter, we will also learn how to use metric aggregations inside bucket aggregations.
In this section, we will go over the following metric aggregations:
- Sum, average, min, and max aggregations
- Stats and extended stats aggregations
- Cardinality aggregations
Let's learn about them, one by one.