Bucket_selector

Bucket selector aggregation

/ Bucket_selector, / Aggregation

Bucket selector aggregation #

A parent pipeline aggregation filtering the bucket list itself: a script predicate per bucket — buckets whose script evaluates false are dropped from the response. It is the HAVING clause of the aggregation world: the predicate sees computed metrics, not documents.

"big_days": {
  "bucket_selector": {
    "buckets_path": { "r": "revenue" },
    "script": "params.r > 150"
  }
}

How it works #

bucket_selector is declared inside the multi-bucket aggregation it decorates, next to the metrics it consumes. After the buckets are built, the engine resolves each named path against every bucket, evaluates the script once as a boolean, and removes the buckets that fail from the owning aggregation’s response. The selector itself never appears in the output — it is a filter, not a metric.

...