Skip to content

Instantly share code, notes, and snippets.

@hkulekci
Created May 27, 2022 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hkulekci/f2fcbc5dad87b9b239937660b05d7480 to your computer and use it in GitHub Desktop.
Save hkulekci/f2fcbc5dad87b9b239937660b05d7480 to your computer and use it in GitHub Desktop.
percentiles aggregation
POST test_index/_bulk
{"index": {"_id": 1}}
{"price": 68}
{"index": {"_id": 2}}
{"price": 74}
{"index": {"_id": 3}}
{"price": 74}
{"index": {"_id": 4}}
{"price": 118}
{"index": {"_id": 5}}
{"price": 119}
{"index": {"_id": 6}}
{"price": 148}
{"index": {"_id": 7}}
{"price": 156}
{"index": {"_id": 8}}
{"price": 163}
{"index": {"_id": 9}}
{"price": 184}
{"index": {"_id": 10}}
{"price": 193}
{"index": {"_id": 11}}
{"price": 196}
{"index": {"_id": 12}}
{"price": 196}
{"index": {"_id": 13}}
{"price": 239}
{"index": {"_id": 14}}
{"price": 252}
{"index": {"_id": 15}}
{"price": 263}
{"index": {"_id": 16}}
{"price": 528}




GET test_index/_search
{
  "size": 0, 
  "aggs": {
    "q1": {
      "percentiles": {
        "field": "price",
        "percents": [
          25,
          50,
          75,
          100
        ],
        "hdr": {                                  
          "number_of_significant_value_digits": 4 
        }
      }
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment