# ClassCast when sorting on a long field (AtomicFieldData$WithOrdinals$1 cannot be cast to AtomicNumericFieldData)

**URL:** <https://discuss.elastic.co/t/classcast-when-sorting-on-a-long-field-atomicfielddata-withordinals-1-cannot-be-cast-to-atomicnumericfielddata/22106>\
**Category:** Elasticsearch\
**Created:** [February 11, 2015, 7:49pm UTC](https://discuss.elastic.co/t/classcast-when-sorting-on-a-long-field-atomicfielddata-withordinals-1-cannot-be-cast-to-atomicnumericfielddata/22106 "2015-02-11T19:49:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_Wittmann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eric_wittmann/32/912_2.png) [@Eric\_Wittmann](https://discuss.elastic.co/u/Eric_Wittmann)\
**Post date:** [February 11, 2015, 7:49pm UTC](https://discuss.elastic.co/t/classcast-when-sorting-on-a-long-field-atomicfielddata-withordinals-1-cannot-be-cast-to-atomicnumericfielddata/22106/1 "2015-02-11T19:49:29Z")

</div>

This problem is really strange because my data has two long fields, and my  
search/filter works for one of them but not the other.

Even weirder, I tried to create a curl reproducer for this with the exact  
same data and that works fine!

Details here:

> <https://gist.github.com/EricWittmann/86864fd897a6f7496fd4>

That shows the mapping of the auditEntry document type. It then shows two  
queries, the first using "id" as the sort. This query fails with:

"QueryPhaseExecutionException[[apiman\_manager][0]:  
query[ConstantScore(cache(\_type:auditEntry))],from[0],size[20],sort[\<custom:  
"id":  
org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@730c1326\>!]:  
Query Failed [Failed to execute main query]]; nested:  
ClassCastException[org.elasticsearch.index.fielddata.AtomicFieldData$WithOrdinals$1  
cannot be cast to org.elasticsearch.index.fielddata.AtomicNumericFieldData];  
"

The second is the same query but sorting on "createdOn". This query seems  
to work fine.

Any help appreciated!

-Eric

PS: Originally found this using ES 1.3.2, but also tested using 1.3.8.

--  
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/28c75509-417d-4355-ac07-f20a30118b87%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/28c75509-417d-4355-ac07-f20a30118b87%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Eric\_Wittmann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eric_wittmann/32/912_2.png) [@Eric\_Wittmann](https://discuss.elastic.co/u/Eric_Wittmann)\
**Post date:** [February 11, 2015, 7:53pm UTC](https://discuss.elastic.co/t/classcast-when-sorting-on-a-long-field-atomicfielddata-withordinals-1-cannot-be-cast-to-atomicnumericfielddata/22106/2 "2015-02-11T19:53:47Z")

</div>

Also note: I'm using the java TransportClient to index the documents. I  
get the ClassCast problem when querying using the TransportClient, but I  
_also_ get the error when querying  
using [http://localhost:9200/\_plugin/marvel/sense/index.html](http://localhost:9200/_plugin/marvel/sense/index.html).

fwiw

--  
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/94305ece-3e91-403e-9fd6-44979be74ac5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/94305ece-3e91-403e-9fd6-44979be74ac5%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:33am UTC](https://discuss.elastic.co/t/classcast-when-sorting-on-a-long-field-atomicfielddata-withordinals-1-cannot-be-cast-to-atomicnumericfielddata/22106/3 "2017-07-06T00:33:24Z")

</div>


