Min bucket aggregation #
A sibling pipeline aggregation identifying the smallest
per-bucket metric value. Bucket aggregations rank groups by their own
key or doc_count; min_bucket answers the orthogonal question — which
of the per-bucket numbers (a revenue, a latency, a rate) is the lowest,
and how low.
"worst_seller": { "min_bucket": { "buckets_path": "per_type>revenue" } }
How it works #
min_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 minimum as a single-value
metric ({"value": 1350}) placed alongside the parent. Only the value
is returned — not which bucket produced it; read the parent’s bucket
list when you need the winner’s key.
The buckets_path names what to collect:
"per_type>revenue"— the>separates the bucket aggregation from the sub-metric inside each bucket; a.separator ("range.v") works identically.- The sub-metric must be single-valued (
sum,avg,min,max,value_count,cardinality, …). Astatssub-agg contributes itssum; multi-value metrics such aspercentilesyield nothing. - A bare parent name (
"per_type") takes each bucket’sdoc_count.
Gaps follow gap_policy:
skip(default) — a bucket whose metric is missing or null is left out, and an empty bucket (doc_count0, e.g. a declaredrangenothing fell into) is skipped even though itssumreads0— so it can never win the minimum.insert_zeros— such buckets contribute0and will typically become the new minimum.
If every bucket is missing, the result is {"value": null}.
Examples #
The four product types bring in 1800, 1800, 1350, 1800, so the
smallest per-type revenue is 1350 — the mug line.
Use cases #
- Find the weakest group — the category, merchant, or region with the lowest total, as one headline number beside the full breakdown.
- Floor of a series — the slowest day in a
date_histogramof daily revenue (over the teaching dataset’s 120 single-sale days the daily minimum is15). - Best-case latency — min of per-service average latencies from a
termsover service names. - Sanity check — a
min_bucketof0usually means an empty bucket slipped in underinsert_zeros, not a real measurement.
Parameters for min_bucket
#
buckets_path
(Required, string) Path to the consumed metric.format
(Optional, string) Output number format. Accepted for compatibility; not applied to the value in the current engine.gap_policy
(Optional, string)skip(default) orinsert_zeros.
Related #
- Sibling family:
avg_bucket,sum_bucket,max_bucket,stats_bucket,extended_stats_bucket,percentiles_bucket - Document-level counterpart:
min