# Histogram aggregation keys

**URL:** <https://discuss.elastic.co/t/histogram-aggregation-keys/18297>\
**Category:** Elasticsearch\
**Created:** [June 24, 2014, 3:31pm UTC](https://discuss.elastic.co/t/histogram-aggregation-keys/18297 "2014-06-24T15:31:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Remi\_Nonnon](https://avatars.discourse-cdn.com/v4/letter/r/f19dbf/32.png) [@Remi\_Nonnon](https://discuss.elastic.co/u/Remi_Nonnon)\
**Post date:** [June 24, 2014, 3:31pm UTC](https://discuss.elastic.co/t/histogram-aggregation-keys/18297/1 "2014-06-24T15:31:51Z")

</div>

Hi,

I'm working with histogram aggregation but there is something strange with  
keys.  
For instance (cf :  
[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-histogram-aggregation.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-histogram-aggregation.html)):

_If I use this request :_

{  
"aggs" : {  
"prices" : {  
"histogram" : {  
"field" : "price",  
"interval" : 50  
}  
}  
}  
}

_I obtain something like this :_

{  
"aggregations": {  
"prices" : {  
"buckets": [  
{

```
                *"key_as_string" : "0",*
                "key": 0,
                "doc_count": 2
            },
            {

                                    *"key_as_string" : "50",*

                "key": 50,
                "doc_count": 4
            },
            {

                                    *"key_as_string" : "150",*

                "key": 150,
                "doc_count": 3
            }
        ]
    }
}

```

}

_Instead of :_

{  
"aggregations": {  
"prices" : {  
"buckets": [  
{  
"key": 0,  
"doc\_count": 2  
},  
{  
"key": 50,  
"doc\_count": 4  
},  
{  
"key": 150,  
"doc\_count": 3  
}  
]  
}  
}  
}

You could say, it's not important but it generates json ~1/3 bigger...  
_Is there a mean to disable this ???_

Moreover, in Elasticsearch Java API, it could be fine to have a method to  
request the response as a hash instead keyed by the buckets keys (cf  
:[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-histogram-aggregation.html#\_response\_format](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-histogram-aggregation.html#_response_format))

_Thanks!!!_

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/47624c50-32d8-4308-b6e5-b07707ad353d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/47624c50-32d8-4308-b6e5-b07707ad353d%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:20am UTC](https://discuss.elastic.co/t/histogram-aggregation-keys/18297/2 "2017-07-06T01:20:08Z")

</div>


