Stats bucket aggregation
/ Stats_bucket, / AggregationStats bucket aggregation #
A sibling pipeline aggregation returning count/min/max/avg/sum of a
metric across buckets — the stats of the per-bucket values. One
call replaces four: where avg_bucket, min_bucket and max_bucket
each reduce the bucket list to a single number, stats_bucket returns
the whole summary object beside the aggregation it describes.
"day_stats": { "stats_bucket": { "buckets_path": "per_day>revenue" } }
How it works #
stats_bucket is declared next to the bucket aggregation it
consumes and runs after every regular aggregation — including the
distributed merge — has finished. It walks the parent’s finished
buckets, collects one number per bucket, and emits the
stats
result object over that sample: