Keys in range aggregation

Hi, is there a particular reason behind the choice to use aggregation keys as bucket keys instead of bucket properties when using range aggregation ?

Example :

{
    ...
    "aggs": {
        "range0-4": {
            "range": {
                "field": "anyValue",
                "ranges": [
                    {
                        "to": 0.5,
                        "key": "0"
                    },
                    {
                        "from": 0.5,
                        "to": 1.5,
                        "key": "1"
                    },
                    {
                        "from": 1.5,
                        "to": 2.5,
                        "key": "2"
                    },
                    {
                        "from": 2.5,
                        "to": 3.5,
                        "key": "3"
                    },
                    {
                        "from": 3.5,
                        "key": "4"
                    }
                ]
            },
            "aggs": {
                "count": {
                    "global": {}
                }
            }
        }
    }
}

Which produces a result like :

{
    ...
    "aggregations" : {
        "range0-4" : {
            "buckets": {
                "0" : {...}
                "1" : {...}
                "2" : {...}
                "3" : {...}
                "4" : {...}
            }
        }
    }
}

Where many other aggregations return keys this way :

{
    ...
    "aggregations" : {
        "terms" : {
            "buckets": [
                {"key" : "0", ...}
                {"key" : "1", ...}
                {"key" : "2", ...}
                {"key" : "3", ...}
                {"key" : "4", ...}
            ]
        }
    }
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.