May 12 2015

Sorting a percentiles aggregation in Elasticsearch

I tried a lot of different things until I arrived at this point...

{
    "aggs": {
        "group_by_normalized_url": {
            "terms": {
                "field": "normalized_url",
                "order": {
                    "90th_percentile[90.0]": "desc"
                }
            },
            "aggs": {
                "90th_percentile": {
                    "percentiles": {
                        "field": "wt",
                        "percents": [
                            90
                        ]
                    }
                }
            }
        }
    }
}
comments powered by Disqus

Info

I'm Ade Slade, a PHP web developer.