Bucket aggregations group matching documents into buckets.
Use bucket aggregations when you want segmented analytics (for example by category, price tier, or time window).
Available Operators#
| Operator | What it groups by |
|---|---|
$terms | Distinct field values |
$range | Explicit from / to ranges |
$histogram | Fixed numeric intervals |
$dateHistogram | Fixed date/time intervals |
$facet | Hierarchical FACET paths |
Input Format#
Every bucket operator takes an object with a field property and operator-specific parameters:
$terms — group by distinct values:
$range — custom range buckets:
$histogram — fixed numeric intervals:
$dateHistogram — fixed time intervals:
Behavior Notes#
- Bucket operators can contain nested
$aggsfor per-bucket metrics. $terms,$range,$histogram, and$dateHistogramsupport nested$aggs.$facetdoes not support nested$aggsand cannot be used as a sub-aggregation.