Percentile Ranks Aggregation
The percentile rank aggregation computes the percentile rank of specific values. Let’s calculate the percentile ranks for prices 300 and 600.
Query
GET /products/_search
{
"size": 0,
"aggs": {
"price_percentile_ranks": {
"percentile_ranks": {
"field": "price",
"values": [300, 600]
}
}
}
}
Output
{
"aggregations": {
"price_percentile_ranks": {
"values": {
"300.0": 30.0,
"600.0": 60.0
}
}
}
}
In this example, prices 300 and 600 fall into the 30th and 60th percentiles, respectively.
Metric Aggregation in Elasticsearch
Elasticsearch is a powerful tool not just for search but also for performing complex data analytics. Metric aggregations are a crucial aspect of this capability, allowing users to compute metrics like averages, sums, and more on numeric fields within their data.
This guide will delve into metric aggregations in Elasticsearch, explaining what they are, how they work, and providing detailed examples to illustrate their use.