Search⌘ K
AI Features

Metric aggregation

Explore metric aggregations in Elasticsearch to calculate sums, averages, min, max, percentiles, and other statistics on numeric fields. This lesson helps you understand how to perform complex data analysis using combined and sub-aggregations for actionable insights.

Overview

Metrics aggregation is a type of aggregation that calculates metric data such as sum or average. It mainly refers to the mathematical calculations performed across a set of documents, usually based on the values of a numerical field present in the document. There are several types of metrics aggregations available in Elasticsearch, each serving a different purpose, such as:

  • Sum aggregation: It calculates the sum of a numeric field across all documents matching the query.

  • Avg aggregation: It computes the average of a numeric field across the matching documents.

  • Min aggregation: It finds the minimum value of a numeric field among the documents.

  • Max aggregation: It determines the maximum value of a numeric field among the documents.

  • Stats aggregation: It provides a collection of basic statistics about a numeric field, including count, sum, average, min, and max.

  • Extended stats aggregation: It is similar to the stats aggregation, but it includes additional statistical information such as standard deviation and variance.

  • Percentiles aggregation: It computes one or more percentiles (e.g., 25th, 50th, and 75th) for a numeric field.

  • Cardinality aggregation: It estimates the distinct count of values in a numeric or keyword field.

  • Value count aggregation: It counts the number of non-null values in a ...