Histogram aggregation

Histogram aggregation #

A multi-bucket aggregation over numeric fields that applies a fixed interval to build the buckets.

Examples #

POST /sales/_search
{
  "aggs": {
    "prices": {
      "histogram": {
        "field": "price",
        "interval": 50
      }
    }
  }
}

Response:

{
  ...
  "aggregations": {
    "prices": {
      "buckets": [
        { "key": 0.0,  "doc_count": 2 },
        { "key": 50.0, "doc_count": 4 },
        { "key": 100.0, "doc_count": 1 }
      ]
    }
  }
}

Parameters for histogram #

  • field
    (Required, string) Field you wish to aggregate (must be numeric).
  • interval
    (Required, number) Bucket width.
  • offset
    (Optional, number, default: 0.0) Shift the bucket boundaries.
  • min_doc_count
    (Optional, integer, default: 0) Only return buckets with at least this many documents.
  • hard_bounds
    (Optional, object) Restrict bucket generation to [min, max) — buckets fully outside are dropped even with min_doc_count: 0.
  • extended_bounds
    (Optional, object) Widen the bucket range beyond the data extent (empty buckets are materialized up to these bounds when min_doc_count is 0). Can only extend, never shrink below the data extent.
  • aggs
    (Optional, object) Nested sub-aggregations, computed per bucket.

For date fields, see the date histogram aggregation.

Calendar September 26, 2026
Edit Edit this page