Percentile_ranks

Percentile ranks aggregation

/ Percentile_ranks, / Aggregation

Percentile ranks aggregation #

A multi-value metrics aggregation that answers the inverse of percentiles: for each value you provide, what percentage of documents is at or below it.

How it works #

The engine collects every value of the field and sorts it once. For each requested value v, the rank is the fraction of collected values that are less than or equal to v:

rank(v) = count(value <= v) / n * 100

The comparison is inclusive — a document exactly at v counts toward its own rank, so the rank of the maximum value is 100, not 100 − 1/n. With no values at all (empty result set, or every document missing the field) each rank is null.

...