# Key\_as\_string formating glued to key

**URL:** <https://discuss.elastic.co/t/key-as-string-formating-glued-to-key/20106>\
**Category:** Elasticsearch\
**Created:** [October 7, 2014, 8:57am UTC](https://discuss.elastic.co/t/key-as-string-formating-glued-to-key/20106 "2014-10-07T08:57:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TJ1](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@TJ1](https://discuss.elastic.co/u/TJ1)\
**Post date:** [October 7, 2014, 8:57am UTC](https://discuss.elastic.co/t/key-as-string-formating-glued-to-key/20106/1 "2014-10-07T08:57:40Z")

</div>

Hi,

I'm doing some experiments on elasticsearch as it looks a very promising solution in our system. While trying to do some date aggregation I've noticed some odd behavior when trying to format date

{  
"aggs": {  
"events": {  
"date\_histogram": {  
"field": "@timestamp",  
"interval": "1d",  
"min\_doc\_count": 0,  
"format" : "yyyy-mm-dd"  
}  
}  
}  
}

I get following response:

{  
"aggregations": {  
"events": {  
"buckets": [  
{  
"key\_as\_string": "yyyy-mm-dd1412467200000",  
"key": 1412467200000,  
"doc\_count": 22  
},  
{  
"key\_as\_string": "yyyy-mm-dd1412553600000",  
"key": 1412553600000,  
"doc\_count": 451  
}  
]  
}  
}  
}

Elastic search version:

"version" : {  
"number" : "1.3.2",  
"build\_hash" : "dee175dbe2f254f3f26992f5d7591939aaefd12f",  
"build\_timestamp" : "2014-08-13T14:29:30Z",  
"build\_snapshot" : false,  
"lucene\_version" : "4.9"  
}

Maybe I'm missing some config's? Elasticsearch is completely new experience for me and it's documentation is far from complete.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 7, 2014, 9:29am UTC](https://discuss.elastic.co/t/key-as-string-formating-glued-to-key/20106/2 "2014-10-07T09:29:06Z")

</div>

At least, you should open an issue and concatenating the format with the value is not what we should do! 🙂

Still, your date format is incorrect. You should use: yyyy-MM-dd I think.

--  
David Pilato | Technical Advocate | [elasticsearch.com](http://elasticsearch.com)  
[david.pilato@elasticsearch.com](mailto:david.pilato@elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 7 octobre 2014 à 10:57:43, TJ (tautvydas@greitai.lt) a écrit:

Hi,

I'm doing some experiments on elasticsearch as it looks a very promising  
solution in our system. While trying to do some date aggregation I've  
noticed some odd behavior when trying to format date

{  
"aggs": {  
"events": {  
"date\_histogram": {  
"field": "@timestamp",  
"interval": "1d",  
"min\_doc\_count": 0,  
"format" : "yyyy-mm-dd"  
}  
}  
}  
}

I get following response:

{  
"aggregations": {  
"events": {  
"buckets": [  
{  
"key\_as\_string": "yyyy-mm-dd1412467200000",  
"key": 1412467200000,  
"doc\_count": 22  
},  
{  
"key\_as\_string": "yyyy-mm-dd1412553600000",  
"key": 1412553600000,  
"doc\_count": 451  
}  
]  
}  
}  
}

Elastic search version:

"version" : {  
"number" : "1.3.2",  
"build\_hash" : "dee175dbe2f254f3f26992f5d7591939aaefd12f",  
"build\_timestamp" : "2014-08-13T14:29:30Z",  
"build\_snapshot" : false,  
"lucene\_version" : "4.9"  
}

Maybe I'm missing some config's? Elasticsearch is completely new experience  
for me and it's documentation is far from complete.

--  
View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/key-as-string-formating-glued-to-key-tp4064499.html](http://elasticsearch-users.115913.n3.nabble.com/key-as-string-formating-glued-to-key-tp4064499.html)  
Sent from the ElasticSearch Users mailing list archive at [Nabble.com](http://Nabble.com).

--  
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/1412672260364-4064499.post%40n3.nabble.com](https://groups.google.com/d/msgid/elasticsearch/1412672260364-4064499.post%40n3.nabble.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/etPan.5433b262.22221a70.7bd4%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.5433b262.22221a70.7bd4%40MacBook-Air-de-David.local).  
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, 12:57am UTC](https://discuss.elastic.co/t/key-as-string-formating-glued-to-key/20106/3 "2017-07-06T00:57:57Z")

</div>


