# Date format for minimum / maximum aggs in beta2

**URL:** <https://discuss.elastic.co/t/date-format-for-minimum-maximum-aggs-in-beta2/14866>\
**Category:** Elasticsearch\
**Created:** [December 14, 2013, 8:44pm UTC](https://discuss.elastic.co/t/date-format-for-minimum-maximum-aggs-in-beta2/14866 "2013-12-14T20:44:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Sick](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@Michael\_Sick](https://discuss.elastic.co/u/Michael_Sick)\
**Post date:** [December 14, 2013, 8:44pm UTC](https://discuss.elastic.co/t/date-format-for-minimum-maximum-aggs-in-beta2/14866/1 "2013-12-14T20:44:32Z")

</div>

Trying to get the min / max dates for a query. Would aggregates be the  
right way to do so? Should the min / max aggs respect the "format":  
"date\_time" property that date histogram does? The Sense query:

GET /vitals/vital/\_search  
{  
"size": 0,  
"query": {  
"match\_all": {}  
},  
"aggs": {  
"min\_time" : {  
"min" : {  
"field" : "recorded\_time",  
"format": "date\_time"  
}  
},  
"max\_time" : {  
"max" : { "field" : "recorded\_time" }  
}  
}  
}

produces:

{  
"took": 4474,  
"timed\_out": false,  
"\_shards": {  
"total": 103,  
"successful": 103,  
"failed": 0  
},  
"hits": {  
"total": 129870443,  
"max\_score": 1,  
"hits": []  
},  
"aggregations": {  
"max\_time": {  
"value": 1732417139462  
},  
"min\_time": {  
"value": 1386850080000  
}  
}  
}

Which I know is a long response time - my laptop is pretty loaded up at the  
moment. Gist @ [https://gist.github.com/mikeasick/7964683](https://gist.github.com/mikeasick/7964683)

If this should be a bug or feature request, let me know and I'll create.  
Advice much appreciated. Thanks --Mike

Michael Sick | Big Data Architect  
Serene Software Inc.

--  
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/CAP8axnBG6oZBLkxczR%3DPgHFmcvwHU1VrT9PM5yHAa9eodzW%2BhA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAP8axnBG6oZBLkxczR%3DPgHFmcvwHU1VrT9PM5yHAa9eodzW%2BhA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![uboness1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/uboness1/32/849_2.png) [@uboness1](https://discuss.elastic.co/u/uboness1)\
**Post date:** [December 16, 2013, 3:32pm UTC](https://discuss.elastic.co/t/date-format-for-minimum-maximum-aggs-in-beta2/14866/2 "2013-12-16T15:32:02Z")

</div>

Hi Michael,

Yes, please open an official issue for it on github.

Thanks,  
Uri

On Saturday, December 14, 2013 12:44:32 PM UTC-8, Michael Sick wrote:

> Trying to get the min / max dates for a query. Would aggregates be the  
> right way to do so? Should the min / max aggs respect the "format":  
> "date\_time" property that date histogram does? The Sense query:
> 
> GET /vitals/vital/\_search  
> {  
> "size": 0,  
> "query": {  
> "match\_all": {}  
> },  
> "aggs": {  
> "min\_time" : {  
> "min" : {  
> "field" : "recorded\_time",  
> "format": "date\_time"  
> }  
> },  
> "max\_time" : {  
> "max" : { "field" : "recorded\_time" }  
> }  
> }  
> }
> 
> produces:
> 
> {  
> "took": 4474,  
> "timed\_out": false,  
> "\_shards": {  
> "total": 103,  
> "successful": 103,  
> "failed": 0  
> },  
> "hits": {  
> "total": 129870443,  
> "max\_score": 1,  
> "hits":   
> },  
> "aggregations": {  
> "max\_time": {  
> "value": 1732417139462  
> },  
> "min\_time": {  
> "value": 1386850080000  
> }  
> }  
> }
> 
> Which I know is a long response time - my laptop is pretty loaded up at  
> the moment. Gist @ [Can't get ElasticSearch minimum / maximum aggregations (aggs) to respect date formatting · GitHub](https://gist.github.com/mikeasick/7964683)
> 
> If this should be a bug or feature request, let me know and I'll create.  
> Advice much appreciated. Thanks --Mike
> 
> Michael Sick | Big Data Architect  
> Serene Software Inc.

--  
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/f27a8402-d425-4bb3-9390-2e8b3a42cf7c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f27a8402-d425-4bb3-9390-2e8b3a42cf7c%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Michael\_Sick](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@Michael\_Sick](https://discuss.elastic.co/u/Michael_Sick)\
**Post date:** [December 16, 2013, 5:26pm UTC](https://discuss.elastic.co/t/date-format-for-minimum-maximum-aggs-in-beta2/14866/3 "2013-12-16T17:26:27Z")

</div>

Done - thanks!

> <https://github.com/elastic/elasticsearch/issues/4467>
>
> The query below with an aggregate on any date field will not respect the "format…" property that date histogram supports. 
> 
> curl -XGET http://localhost:9200/vitals/vital/\_search?pretty=true -d '
> {
> "size": 0,
> "query": {
> "match\_all": {}
> },
> "aggs": {
> "minimum\_vitals\_datetime" : {
> "min" : {
> "field" : "recorded\_time",
> "format": "date\_time"
> }
> }
> }
> }'
> 
> result is:
> 
> {
> "took" : 2342,
> "timed\_out" : false,
> "\_shards" : {
> "total" : 1,
> "successful" : 1,
> "failed" : 0
> },
> "hits" : {
> "total" : 67733027,
> "max\_score" : 1.0,
> "hits" : \[\]
> },
> "aggregations" : {
> "minimum\_vitals\_datetime" : {
> "value" : 1.38685008E12
> }
> }
> }
> 
> without a formatted version.

On Mon, Dec 16, 2013 at 10:32 AM, uboness [uri.boness@elasticsearch.com](mailto:uri.boness@elasticsearch.com)wrote:

> Hi Michael,
> 
> Yes, please open an official issue for it on github.
> 
> Thanks,  
> Uri
> 
> On Saturday, December 14, 2013 12:44:32 PM UTC-8, Michael Sick wrote:
> 
> > Trying to get the min / max dates for a query. Would aggregates be the  
> > right way to do so? Should the min / max aggs respect the "format":  
> > "date\_time" property that date histogram does? The Sense query:
> > 
> > GET /vitals/vital/\_search  
> > {  
> > "size": 0,  
> > "query": {  
> > "match\_all": {}  
> > },  
> > "aggs": {  
> > "min\_time" : {  
> > "min" : {  
> > "field" : "recorded\_time",  
> > "format": "date\_time"  
> > }  
> > },  
> > "max\_time" : {  
> > "max" : { "field" : "recorded\_time" }  
> > }  
> > }  
> > }
> > 
> > produces:
> > 
> > {  
> > "took": 4474,  
> > "timed\_out": false,  
> > "\_shards": {  
> > "total": 103,  
> > "successful": 103,  
> > "failed": 0  
> > },  
> > "hits": {  
> > "total": 129870443,  
> > "max\_score": 1,  
> > "hits":   
> > },  
> > "aggregations": {  
> > "max\_time": {  
> > "value": 1732417139462  
> > },  
> > "min\_time": {  
> > "value": 1386850080000  
> > }  
> > }  
> > }
> > 
> > Which I know is a long response time - my laptop is pretty loaded up at  
> > the moment. Gist @ [Can't get ElasticSearch minimum / maximum aggregations (aggs) to respect date formatting · GitHub](https://gist.github.com/mikeasick/7964683)
> > 
> > If this should be a bug or feature request, let me know and I'll create.  
> > Advice much appreciated. Thanks --Mike
> > 
> > Michael Sick | Big Data Architect  
> > Serene Software Inc.
> > 
> > --  
> > 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/f27a8402-d425-4bb3-9390-2e8b3a42cf7c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f27a8402-d425-4bb3-9390-2e8b3a42cf7c%40googlegroups.com)  
> > .  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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/CAP8axnBMHe-pRGhTfVvso8\_htV3FnKP8gU0Qez9ChAdxstd31w%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAP8axnBMHe-pRGhTfVvso8_htV3FnKP8gU0Qez9ChAdxstd31w%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:00am UTC](https://discuss.elastic.co/t/date-format-for-minimum-maximum-aggs-in-beta2/14866/4 "2017-07-06T02:00:53Z")

</div>


