Min bucket aggregation

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, …). A stats sub-agg contributes its sum; multi-value metrics such as percentiles yield nothing.
  • A bare parent name ("per_type") takes each bucket’s doc_count.

Gaps follow gap_policy:

  • skip (default) — a bucket whose metric is missing or null is left out, and an empty bucket (doc_count 0, e.g. a declared range nothing fell into) is skipped even though its sum reads 0 — so it can never win the minimum.
  • insert_zeros — such buckets contribute 0 and 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_histogram of daily revenue (over the teaching dataset’s 120 single-sale days the daily minimum is 15).
  • Best-case latency — min of per-service average latencies from a terms over service names.
  • Sanity check — a min_bucket of 0 usually means an empty bucket slipped in under insert_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) or insert_zeros.
Calendar October 6, 2026
Edit Edit this page