# Getting Exception while running Stats-Aggregation in Elasticsearch 1.6

**URL:** <https://discuss.elastic.co/t/getting-exception-while-running-stats-aggregation-in-elasticsearch-1-6/39318>\
**Category:** Elasticsearch\
**Created:** [January 15, 2016, 10:40am UTC](https://discuss.elastic.co/t/getting-exception-while-running-stats-aggregation-in-elasticsearch-1-6/39318 "2016-01-15T10:40:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhay](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@Abhay](https://discuss.elastic.co/u/Abhay)\
**Post date:** [January 15, 2016, 10:40am UTC](https://discuss.elastic.co/t/getting-exception-while-running-stats-aggregation-in-elasticsearch-1-6/39318/1 "2016-01-15T10:40:36Z")

</div>

I have 2 index types a) Custom\_Pattern\_1, b) Custom\_DataType\_2 inside 'bw-2016-01-15-06-006' index. For both of these index types, I have two field of same name but different data types

> Custom\_Pattern\_1- Custom\_DataType - String  
> Custom\_DataType\_2 - Custom\_DataType - Long

I am running below query for aggregation.

```
POST bw-2016-01-15-06-006/Custom_DataType_2/_search
{
  "from" : 0,
  "size" : 100,
  "aggregations" : {
        "Custom_DataType" : {
          "extended_stats" : {
            "field" : "Custom_DataType"
          }
        }
      }
}

```

Though I am running query only on Custom\_DataType2 inside 'bw-2016-01-15-06-006' index in which Custom\_DataType is long, it should have returned the results. But I am getting below ClassCastException.

```
{
   "error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[-lo5bj-4TLOcyZwfl6oPyA][bw-2016-01-15-06-006][0]: ClassCastException[org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be cast to org.elasticsearch.index.fielddata.IndexNumericFieldData]}{[-lo5bj-4TLOcyZwfl6oPyA][bw-2016-01-15-06-006][1]: ClassCastException[org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be cast to org.elasticsearch.index.fielddata.IndexNumericFieldData]}{[-lo5bj-4TLOcyZwfl6oPyA][bw-2016-01-15-06-006][2]: ClassCastException[org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be cast to org.elasticsearch.index.fielddata.IndexNumericFieldData]}{[-lo5bj-4TLOcyZwfl6oPyA][bw-2016-01-15-06-006][3]: ClassCastException[org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be cast to org.elasticsearch.index.fielddata.IndexNumericFieldData]}]",
   "status": 500
}

```

I am still using Elasticsearch 1.6 and according to documents one index can have 2 fields of same name with different data types. Can somebody help me on this

---

<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 5, 2017, 11:24pm UTC](https://discuss.elastic.co/t/getting-exception-while-running-stats-aggregation-in-elasticsearch-1-6/39318/2 "2017-07-05T23:24:10Z")

</div>


