Stats

Stats aggregation

/ Stats, / Aggregation

Stats aggregation #

A multi-value metrics aggregation that computes basic statistics (min, max, sum, count, avg) over numeric values extracted from the aggregated documents. It is avg, min, max and sum folded into one request — the five numbers most dashboards put side by side, for the price of one column scan.

How it works #

The engine walks the matching documents once, maintaining a running count, sum, minimum and maximum; avg is derived at the end as sum / count. Everything is exact — no sampling, no sketches. Values are coerced to doubles as they are read: integers, floats and booleans (true = 1, false = 0) contribute, non-numeric values such as keyword strings do not.

...