Elasticsearch does not sort on double field

I am querying index in ES using below code

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?

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