Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird calculation of the percentile ranks #26156

Closed
kirolos-kaldas opened this issue Aug 11, 2017 · 1 comment
Closed

Weird calculation of the percentile ranks #26156

kirolos-kaldas opened this issue Aug 11, 2017 · 1 comment

Comments

@kirolos-kaldas
Copy link

Hi,

I have the following list of data:
[22,22,25,26,2730,31,31,32,32,32,36,36,36,38,25,26,27,38,40]

when I use the following query to get the percentile ranks for the given values
{
"aggregations" : {
"agg" : {
"percentile_ranks" : {
"field" : "score",
"values" : [40, 40.5]
}
}
}
}

I get the following:
{
"took" : 5,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 19,
"max_score" : 1.0,
"hits" : [ ]
},
"aggregations" : {
"agg" : {
"values" : {
"40": 91.176,
"40.5": 92.647
}
}
}
}

40 is the highest value , so shouldn't 40.5 be 100?
is this value returned from elasticsearch correct or is this a bug?
If its correct then, how is the percentile rank calculated to give you this value?

@markharwood
Copy link
Contributor

The docs for percentiles and percentile ranks note that these are approximate and give details behind this approach.

You can always add a "max" aggregation to your request which will be accurate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants