Elasticsearch provides an aggregation module to retrieve the analytic information on the huge dataset indexed in Elasticsearch. Aggregations are similar to what we knew as the GROUP BY
clause and aggregate functions in the relational database world. You can execute aggregations on a subset of the overall indexed data by restricting the dataset using any Elasticsearch query that you learned in the last section. Each cluster node locally executes aggregations. The result collected by each node is then aggregated to derive the final aggregation result.
Aggregations can be categorized into two broad types:
Bucketing: This type of aggregation can be seen as the enriched
GROUP BY
clause of SQL. It categorizes documents into buckets based on a specific criterion.Metrics: These are similar to the aggregate functions of SQL. They perform computations, such as
simple count
,average
,sum
,percentile
, and so on, on a specified field of the document set.