Stats aggregation

Stats aggregation #

A multi-value metrics aggregation that computes basic statistics (min, max, sum, count, avg) over numeric values extracted from the aggregated documents.

Examples #

POST /sales/_search
{
  "aggs": {
    "prices_stats": {
      "stats": {
        "field": "price"
      }
    }
  }
}

Response:

{
  ...
  "aggregations": {
    "prices_stats": {
      "count": 9,
      "min": 72.0,
      "max": 99.0,
      "avg": 86.0,
      "sum": 774.0
    }
  }
}

Parameters for stats #

  • field
    (Required, string) Field you wish to aggregate.
  • missing
    (Optional, value) Value used for documents missing the field.

extended_stats takes the same parameters and additionally returns variance, standard deviation and related statistics.

Calendar September 26, 2026
Edit Edit this page