Global aggregation

Global aggregation #

A single-bucket aggregation whose nested aggregations run over all documents in the search context, ignoring the query scope.

Examples #

Compare the query’s average price against the whole dataset’s:

POST /sales/_search
{
  "query": { "term": { "field": "type", "value": "t-shirt" } },
  "aggs": {
    "all_products": {
      "global": {},
      "aggs": {
        "avg_price": { "avg": { "field": "price" } }
      }
    }
  }
}

Parameters for global #

  • aggs
    (Required, object) Nested sub-aggregations — the whole point of global: they run over every document, not just the query’s matches.
Calendar September 26, 2026
Edit Edit this page