Skip to content

Wrong Percentile Rank calculation #14851

@rcrezende

Description

@rcrezende

I'm getting unexpected results with percentile rank statistic:

Request:

PUT percenttest
{
  "settings": {
    "number_of_shards": 1, 
    "number_of_replicas": 0
  }
}
POST percenttest/doc/1
{
  "i": 2.7
}
POST percenttest/doc/2
{
  "i": 85.9
}
POST percenttest/doc/3
{
  "i": 11.9
}
POST percenttest/doc/4
{
  "i": 51.5
}
GET percenttest/_search?search_type=count
{
  "aggs": {
    "percent_rank": {
      "percentile_ranks": {
        "field": "i",
        "values": [
          1,2,3,4,11,12,50,52,70,85,86,87
        ]
      }
    }
  }
}

Response:

{
   "took": 1,
   "timed_out": false,
   "_shards": {
      "total": 1,
      "successful": 1,
      "failed": 0
   },
   "hits": {
      "total": 4,
      "max_score": 0,
      "hits": []
   },
   "aggregations": {
      "percent_rank": {
         "values": {
            "1.0": 7.8804347826086945,
            "2.0": 10.597826086956522,
            "3.0": 13.31521739130435,
            "4.0": 16.032608695652172,
            "11.0": 28.790983606557376,
            "12.0": 29.815573770491806,
            "50.0": 36.40988372093024,
            "52.0": 37.86337209302326,
            "70.0": 50.94476744186046,
            "85.0": 61.84593023255813,
            "86.0": 62.57267441860465,
            "87.0": 63.29941860465116
         }
      }
   }
}

But there is no element < 2 and I'm getting 10.6% for that.
Also 100% of values are < 87, but I'm getting 65.3%.

Using ES 1.6

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions