# Min, max aggregations on date type fields

**URL:** <https://discuss.elastic.co/t/min-max-aggregations-on-date-type-fields/108380>\
**Category:** Elasticsearch\
**Created:** [November 20, 2017, 12:11pm UTC](https://discuss.elastic.co/t/min-max-aggregations-on-date-type-fields/108380 "2017-11-20T12:11:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nugusbayevkk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nugusbayevkk/32/126683_2.png) [@nugusbayevkk](https://discuss.elastic.co/u/nugusbayevkk)\
**Post date:** [November 20, 2017, 12:11pm UTC](https://discuss.elastic.co/t/min-max-aggregations-on-date-type-fields/108380/1 "2017-11-20T12:11:43Z")

</div>

hello guys,  
i notice that in current version don't work min, max aggregations on "date" type fields.  
i try to execute

> var params = {  
> body: {  
> size: 0,  
> query: {  
> bool: {  
> must: [  
> {  
> range: {  
> 'event\_date': qrange  
> }  
> },  
> {  
> match: {  
> critical\_degree: request.payload.critical\_degree  
> }  
> }  
> ]  
> }  
> },  
> aggs: {  
> agg\_event\_name: {  
> terms: {  
> field: "event\_name",  
> size: 100  
> },  
> aggs: {  
> last\_time: {  
> max: {  
> field: "event\_date"  
> }  
> },  
> first\_time: {  
> min: {  
> field: "event\_date"  
> }  
> }  
> }  
> }  
> }  
> }  
> };
> 
> ```
> var matchCondition = {};
> matchCondition.match = {};
> matchCondition.match[request.payload.type] = request.payload.value;
> 
> params.body.query.bool.must.push(matchCondition);
> 
> ```

field event\_date has type "date"

then i try to set fielddata on true. but elasticsearch don't allowed do it.

so after i try add keyword

"event\_date" : {  
"type" : "date",  
"fields" : {  
"keyword" : {  
"type" : "keyword"  
}  
}  
},

but elasticsearch return same exception:

Fielddata is disabled on text fields by default. Set fielddata=true on [event\_date] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.

any advice?

---

<div class="post-metadata">

**Author:** ![nugusbayevkk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nugusbayevkk/32/126683_2.png) [@nugusbayevkk](https://discuss.elastic.co/u/nugusbayevkk)\
**Post date:** [November 20, 2017, 12:37pm UTC](https://discuss.elastic.co/t/min-max-aggregations-on-date-type-fields/108380/2 "2017-11-20T12:37:07Z")

</div>

guys, my bad. i don't set index in callWithRequest, so elasticsearch try execute query on another indices.  
min, max is working correct. thanks

---

<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:** [December 18, 2017, 12:37pm UTC](https://discuss.elastic.co/t/min-max-aggregations-on-date-type-fields/108380/3 "2017-12-18T12:37:11Z")

</div>

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