Skip to main content

Aggregations for Elasticsearchs

Elasticsearch aggregations compute summaries over the documents a query matches. Metric aggregations such as avg and cardinality produce single numbers, bucket aggregations such as terms and date_histogram group documents, and the results usually feed charts and dashboards in Kibana.

Stage: Analytics · Part of the Elasticsearch roadmap · Last reviewed 19 November 2026

What to learn in Aggregations

Aggregations interview questions

Why does a terms aggregation need a keyword field?

Aggregations work on per-document values, which keyword fields store in doc values. Text fields are analyzed into tokens and have no doc values by default, so aggregating on them would group by individual words, or fail unless fielddata is enabled.

Is the cardinality aggregation exact?

No. It uses the HyperLogLog++ algorithm to give an approximate count of distinct values with bounded memory. It is accurate for small counts and trades a small error for speed on high-cardinality fields, with a precision threshold you can configure.

Where Aggregations fits in the Elasticsearch roadmap

Aggregations belongs to the Analytics stage (intermediate level). Aggregations.

Back to the full Elasticsearch roadmap