Max bucket aggregation
/ Max_bucket, / AggregationMax bucket aggregation #
A sibling pipeline aggregation identifying the largest per-bucket
metric value — e.g. the best-performing group. Bucket aggregations can
sort their own output, but only inside one request’s bucket list;
max_bucket lifts the winning number out as a single headline metric
next to the breakdown.
"best_seller": { "max_bucket": { "buckets_path": "per_type>revenue" } }
How it works #
max_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 returns their maximum as a single-value
metric ({"value": 1800}) placed alongside the parent. Only the value
is returned — not which bucket produced it; read the parent’s bucket
list (or sort it with
bucket_sort) when you need
the winner’s key.