# Aggregations value formatter - on a multi indices query

**URL:** <https://discuss.elastic.co/t/aggregations-value-formatter-on-a-multi-indices-query/70076>\
**Category:** Elasticsearch\
**Created:** [December 27, 2016, 2:50pm UTC](https://discuss.elastic.co/t/aggregations-value-formatter-on-a-multi-indices-query/70076 "2016-12-27T14:50:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![LiorY89](https://avatars.discourse-cdn.com/v4/letter/l/5f9b8f/32.png) [@LiorY89](https://discuss.elastic.co/u/LiorY89)\
**Post date:** [December 27, 2016, 2:50pm UTC](https://discuss.elastic.co/t/aggregations-value-formatter-on-a-multi-indices-query/70076/1 "2016-12-27T14:50:13Z")

</div>

I'm trying to find the min date on documents of an index.  
All works good if i'm trying to do it on a specific index, such as:

```
GET index1/_search
{
  "size": 0,
  "aggs": {
    "min_date": {
      "min": {
        "field": "date_of_birth"
      }
    }
  }
}

```

The results is good, and i'm getting the value as string:

"took": 1,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 545,  
"max\_score": 0,  
"hits": []  
},  
"aggregations": {  
"min\_date": {  
"value": -155865600000,  
"value\_as\_string": "23/01/1965"  
}  
}  
}

but when i'm adding the search on index2 also, which doesn't have this field:

```
GET index1,index2/_search
{
  "size": 0,
  "aggs": {
    "min_date": {
      "min": {
        "field": "date_of_birth"
      }
    }
  }
}

```

The result is in milis only (in the code, i see that the formatter is Raw and not DateTime):  
{  
"took": 1,  
"timed\_out": false,  
"\_shards": {  
"total": 10,  
"successful": 10,  
"failed": 0  
},  
"hits": {  
"total": 1069,  
"max\_score": 0,  
"hits": []  
},  
"aggregations": {  
"min\_date": {  
"value": -155865600000  
}  
}  
}

Is there a way to solve this?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [December 29, 2016, 9:36am UTC](https://discuss.elastic.co/t/aggregations-value-formatter-on-a-multi-indices-query/70076/2 "2016-12-29T09:36:11Z")

</div>

Hey,

is it possible that the `date_of_birth` field is mapped to a different type in your other index? I just tested with Elasticsearch 5.1.1 and not having such a field in `index2` still formatted everything as expected. I might be missing something - can you provide a full reproduction?

--Alex

---

<div class="post-metadata">

**Author:** ![LiorY89](https://avatars.discourse-cdn.com/v4/letter/l/5f9b8f/32.png) [@LiorY89](https://discuss.elastic.co/u/LiorY89)\
**Post date:** [January 1, 2017, 4:42pm UTC](https://discuss.elastic.co/t/aggregations-value-formatter-on-a-multi-indices-query/70076/3 "2017-01-01T16:42:54Z")

</div>

It took my a while, but i think it something to do with the indices names.  
I took those mappings:

PUT lala  
{  
"mappings": {  
"type1": {  
"properties": {  
"date\_of\_birth": {  
"type": "date",  
"format": "dd/MM/yyyy"  
}  
}  
}  
}  
}

PUT index2  
{  
"mappings": {  
"type2": {  
"properties": {  
"name": {  
"type": "string"  
}  
}  
}  
}  
}

POST lala/type1  
{  
"date\_of\_birth" : "07/12/1989"  
}

GET lala,index2/\_search  
{  
"size": 0,  
"aggs": {  
"tata": {  
"min": {  
"field": "date\_of\_birth"  
}  
}  
}  
}

and the problem occures, but if i change the indices to index1 and index2 so there is no problem...

---

<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:** [January 29, 2017, 4:43pm UTC](https://discuss.elastic.co/t/aggregations-value-formatter-on-a-multi-indices-query/70076/4 "2017-01-29T16:43:27Z")

</div>

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