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 ofglobal: they run over every document, not just the query’s matches.