# ClassCastException

**URL:** <https://discuss.elastic.co/t/classcastexception/118764>\
**Category:** Elasticsearch\
**Created:** [February 7, 2018, 7:05am UTC](https://discuss.elastic.co/t/classcastexception/118764 "2018-02-07T07:05:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![huajing](https://avatars.discourse-cdn.com/v4/letter/h/977dab/32.png) [@huajing](https://discuss.elastic.co/u/huajing)\
**Post date:** [February 7, 2018, 7:05am UTC](https://discuss.elastic.co/t/classcastexception/118764/1 "2018-02-07T07:05:23Z")

</div>

Hi guys:  
There is a mistake here about elasticsearch1.7.5 :  
{  
"error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[EklIxB3jTH2gBt6-sjT6wA][i\_dsrhx][0]: ClassCastException[org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be cast to org.elasticsearch.index.fielddata.IndexNumericFieldData]}{[yro95n9hSsaROrA1oPCOTQ][i\_dsrhx][1]: RemoteTransportException[[node39][inet[/172.16.32.39:9300]][indices:data/read/search[phase/query]]]; nested: ClassCastException[org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be cast to org.elasticsearch.index.fielddata.IndexNumericFieldData]; }{[SPXGeONTROGMG2poPJkq8w][i\_dsrhx][2]: RemoteTransportException[[node38][inet[/172.16.32.38:9300]][indices:data/read/search[phase/query]]]; nested: ClassCastException[org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be cast to org.elasticsearch.index.fielddata.IndexNumericFieldData]; }{[9jUAFgprR1GO2xXw0\_fXRw][i\_dsrhx][3]: RemoteTransportException[[node220][inet[/172.16.32.220:9300]][indices:data/read/search[phase/query]]]; nested: ClassCastException[org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be cast to org.elasticsearch.index.fielddata.IndexNumericFieldData]; }]",  
"status": 500  
}

The mapping is {  
"i\_dsrhx": {  
"mappings": {  
"t\_dsrzb": {  
"\_id": {  
"path": "\_ID"  
},  
"properties": {  
"C\_AJEJFL": {  
"type": "string",  
"index": "not\_analyzed"  
},  
"C\_AJYJFL": {  
"type": "string",  
"index": "not\_analyzed"  
},  
"C\_AY": {  
"type": "string",  
"index": "not\_analyzed"  
},  
"C\_AYDM": {  
"type": "string",  
"index": "not\_analyzed"  
},  
"C\_DSRBH": {  
"type": "string",  
"index": "not\_analyzed"  
},  
"C\_DSRMC": {  
"type": "string",  
"index": "not\_analyzed"  
},  
"C\_EJAJFL": {  
"type": "string"  
},  
"C\_YJAJFL": {  
"type": "string"  
},  
"DT\_ZHXGSJ": {  
"type": "string"  
},  
"N\_AJS": {  
"type": "long"  
},  
"N\_CFQSCS": {  
"type": "long"  
},  
"N\_DSRLX": {  
"type": "long"  
},  
"N\_FKCS": {  
"type": "long"  
},  
"N\_FXCS": {  
"type": "long"  
},  
"N\_GBZXCS": {  
"type": "long"  
},  
"N\_GZAJCD": {  
"type": "long"  
},  
"N\_KJZXCS": {  
"type": "long"  
},  
"N\_SDCS": {  
"type": "long"  
},  
"N\_SFJLCS": {  
"type": "long"  
},  
"N\_SFJZCS": {  
"type": "long"  
},  
"N\_SJDLGX": {  
"type": "long"  
},  
"N\_SSBL": {  
"type": "double"  
},  
"N\_SXCS": {  
"type": "long"  
},  
"N\_XSJLCS": {  
"type": "long"  
},  
"N\_YJAJS": {  
"type": "long"  
},  
"N\_ZSAJS": {  
"type": "long"  
},  
"N\_ZXDWL": {  
"type": "double"  
},  
"\_ID": {  
"type": "string",  
"index": "not\_analyzed"  
}  
}  
}  
}  
}  
}

i used javaAPI like this SumBuilder ajsSb = AggregationBuilders.sum("ajs").field("N\_AJS");

any idears?

---

<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:** [February 7, 2018, 8:37am UTC](https://discuss.elastic.co/t/classcastexception/118764/2 "2018-02-07T08:37:09Z")

</div>

Could you reproduce it with a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). Please, try to keep the example as simple as possible.

Would be better to reproduce on a recent version as 1.7 is not supported anymore.

---

<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:** [March 7, 2018, 8:37am UTC](https://discuss.elastic.co/t/classcastexception/118764/3 "2018-03-07T08:37:13Z")

</div>

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