13 Aggregations
This chapter covers
- Aggregation basics
- Working with metric aggregations
- Categorizing data using bucket aggregations
- Chaining metric and bucket aggregations in pipeline aggregations
Search and analytics are two sides of a coin, and Elasticsearch delivers both with absolute detail and countless features. Elasticsearch is a market leader in analytics by providing the feature-rich functions for querying and analyzing data, thus enabling organizations to find insights and deep intelligence from their data. Although a search finds results for certain criteria, analytics, on the other hand, helps organizations derive statistics and metrics from it. So far, we've looked at searching for documents from a given corpus of documents. With analytics, we take a step back and look at the data from a high level to draw conclusions about it.
In this chapter, we’ll look at Elasticsearch's aggregations in detail. Elasticsearch boasts a large number of aggregations, predominantly categorized into one of these types: metric, bucket, and pipeline. Metric aggregations allow us to use analytical functions such as sum, min, max, or average for calculations on the data; bucket aggregations help us to categorize data into buckets or ranges. Finally, pipeline aggregations permit us to chain aggregations, meaning that they take metric or bucket aggregations and create new aggregations.