# Sorting on long float field doesnt work correctly (ES 1.3.4)

**URL:** <https://discuss.elastic.co/t/sorting-on-long-float-field-doesnt-work-correctly-es-1-3-4/20180>\
**Category:** Elasticsearch\
**Created:** [October 10, 2014, 12:50pm UTC](https://discuss.elastic.co/t/sorting-on-long-float-field-doesnt-work-correctly-es-1-3-4/20180 "2014-10-10T12:50:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Marko](https://avatars.discourse-cdn.com/v4/letter/d/ba8739/32.png) [@David\_Marko](https://discuss.elastic.co/u/David_Marko)\
**Post date:** [October 10, 2014, 12:50pm UTC](https://discuss.elastic.co/t/sorting-on-long-float-field-doesnt-work-correctly-es-1-3-4/20180/1 "2014-10-10T12:50:25Z")

</div>

I have a problem with uncorrect sorting based on float type field. I have a  
float type field in my data called 'gtd\_sort\_number' (see data example  
below). Value is a microtime so its quite long with decimal values (as on  
example below). Now when I do a query like below (2nd example), the result  
set is not sorted correctly. Some items are in correct order some not.  
First example shows data returned from query so you can see "sort": [  
1412944380] addded to the result. This seems to me that ES rounds the  
former values somehow and then sorts it so it produces wrong results  
because it rounds different(similar) values to the same value.

Any idea whats wrong here?

{  
"\_index": "netnotes",  
"\_type": "activity",  
"\_id": "a53ab53ba52b3f03bf8e547a0633dc3f",  
"\_score": null,  
"\_source": {  
"id": "a53ab53ba52b3f03bf8e547a0633dc3f",  
"gtd\_sort\_number": 1412944355.6989,  
"gtd\_section\_id": "37aee9eb-e836-41f1-89a8-8d173fe23d57",  
"gtd\_board\_id": "0d7b113b24d53a5a9ca50345173c4c49",  
"gtd\_color": "#000000",  
"gtd\_type": "note",  
"gtd\_label": "",  
"gtd\_private": null  
},  
"sort": [  
1412944380  
]  
}  
]  
}

Query example

GET /netnotes/activity/\_search  
{"query":{"match\_all":{}},"post\_filter":{"term":{"gtd\_board\_id":  
"0d7b113b24d53a5a9ca50345173c4c49"}},"sort":{"gtd\_sort\_number":"desc"},  
"from":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/cb8db594-3bf1-4e4c-a338-0148270586e8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/cb8db594-3bf1-4e4c-a338-0148270586e8%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:57am UTC](https://discuss.elastic.co/t/sorting-on-long-float-field-doesnt-work-correctly-es-1-3-4/20180/2 "2017-07-06T00:57:04Z")

</div>


