# Sorting with \_geo\_distance will throw ClassCastException exception

**URL:** <https://discuss.elastic.co/t/sorting-with--geo-distance-will-throw-classcastexception-exception/16710>\
**Category:** Elasticsearch\
**Created:** [March 31, 2014, 9:08am UTC](https://discuss.elastic.co/t/sorting-with--geo-distance-will-throw-classcastexception-exception/16710 "2014-03-31T09:08:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yp\_yean](https://avatars.discourse-cdn.com/v4/letter/y/e9c0ed/32.png) [@yp\_yean](https://discuss.elastic.co/u/yp_yean)\
**Post date:** [March 31, 2014, 9:08am UTC](https://discuss.elastic.co/t/sorting-with--geo-distance-will-throw-classcastexception-exception/16710/1 "2014-03-31T09:08:01Z")

</div>

created index with mapping:

"mappings": {  
"city": {  
"properties": {  
"name": {  
"type": "string",  
"store": "yes",  
"index": "analyzed"  
},  
"location": {  
"type": "geo\_point"  
}  
}  
}  
}

and search/sort with \_geo\_distance:

"query": {  
"match\_all": {}  
},  
"fields": "name",  
"sort": {  
"\_geo\_distance": {  
"location": [  
121.571079,  
25.049787  
],  
"unit": "km"  
}  
}

will throw  
ClassCastException[org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData  
cannot be cast to org.elasticsearch.index.fielddata.IndexGeoPointFieldData]  
exception.

Elasticsearch version: 1.1.0

--  
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/e45d5add-3f74-4c02-9748-9c100d5b4f34%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e45d5add-3f74-4c02-9748-9c100d5b4f34%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)\
**Post date:** [March 31, 2014, 9:48pm UTC](https://discuss.elastic.co/t/sorting-with--geo-distance-will-throw-classcastexception-exception/16710/2 "2014-03-31T21:48:50Z")

</div>

Do you have any steps to reproduce? I'm very curious what causes this.  
Thanks!

--  
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/921ef95b-8943-4613-99ea-71d5934c0b51%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/921ef95b-8943-4613-99ea-71d5934c0b51%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, 1:39am UTC](https://discuss.elastic.co/t/sorting-with--geo-distance-will-throw-classcastexception-exception/16710/3 "2017-07-06T01:39:11Z")

</div>


