Metric aggregations
Metric aggregations work with numeric data, computing one or more aggregate metrics within the given context. The context could 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 the chapter, we will also learn how to use metric aggregations inside bucket aggregations.
We will learn about the following metric aggregations:
- Sum, average, min, and max aggregations
- Stats and extended stats aggregations
- Cardinality aggregation
Let us learn about them one by one.
Sum, average, min, and max aggregations
Finding the sum of a field, the minimum value for a field, the maximum value for a field, or an average, are very common operations. For the people who are familiar with...