# Elasticsearch does not sort on double field

**URL:** <https://discuss.elastic.co/t/elasticsearch-does-not-sort-on-double-field/205222>\
**Category:** Elasticsearch\
**Created:** [October 25, 2019, 9:44am UTC](https://discuss.elastic.co/t/elasticsearch-does-not-sort-on-double-field/205222 "2019-10-25T09:44:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![May](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@May](https://discuss.elastic.co/u/May)\
**Post date:** [October 25, 2019, 9:44am UTC](https://discuss.elastic.co/t/elasticsearch-does-not-sort-on-double-field/205222/1 "2019-10-25T09:44:18Z")

</div>

I am querying index in ES using below code

```auto
def cat_results_tmp(response,field):
	results=[]
	for hit in response['hits']['hits']:
		result_tuple = (
						hit["_source"][field]
						)
		results.append(result_tuple)
	return results       

def categories3(cat_sort_field="", sort_order=""):
	client = Elasticsearch([{'host':localhost,'port':9200}])
	response = client.search( \
	index="cat_test", \
	body={\
       "query": { "match_all": {} }
	   ,"sort" : [
		 { cat_sort_field: {"order" : sort_order} }]
		,"size":100
		}
		)
	print(response)
	response3=cat_results_tmp(response,cat_sort_field)
	return response3

```

I tried with multiple fields for my index and all double fields can be sorted, I get `'sort': [0]` for the printed response, while float fields work fine.

Also double fields cannot be changed into float fields with mapping after indexing. How to solve this except for create a custom mapping while indexing?

---

<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:** [November 22, 2019, 9:44am UTC](https://discuss.elastic.co/t/elasticsearch-does-not-sort-on-double-field/205222/2 "2019-11-22T09:44:21Z")

</div>

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