# Date Formatting Issue + Sorting by Float

**URL:** <https://discuss.elastic.co/t/date-formatting-issue-sorting-by-float/18552>\
**Category:** Elasticsearch\
**Created:** [July 9, 2014, 9:08am UTC](https://discuss.elastic.co/t/date-formatting-issue-sorting-by-float/18552 "2014-07-09T09:08:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mullac](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mullac/32/1415_2.png) [@Mullac](https://discuss.elastic.co/u/Mullac)\
**Post date:** [July 9, 2014, 9:08am UTC](https://discuss.elastic.co/t/date-formatting-issue-sorting-by-float/18552/1 "2014-07-09T09:08:58Z")

</div>

Hi,

I have a date and a unix timestamp field in my mapping. Experiencing  
several issues..

1. I cannot get Elasticsearch to accept any kind of date format I have  
tried for the date field
2. Sorting on the unix timestamp field is not working (which is type  
float)
3. Unable to filter on the unix timestamp field ("No filtered registered  
for [tstamp\_unix]

Example of the data going in (note the fractions of a second):

{  
"tstamp" : "2014-07-09 08:33:04.178900",  
"tstamp\_unix" : 1404894784.178900  
}

I'm aware I don't need the unix value however as the mapping just wasn't  
working and date is now set to type string. In terms of mapping I have  
tried:

{  
"type1": {  
"tstamp": {  
"type" : "date",  
"format" : "yyyy-MM-dd HH:mm:ss.S" // also yyyy-MM-dd  
HH:mm:ss.SSS, y-M-d H:m:s.S etc etc  
}  
}  
}

Then with the sorting - tstamp\_unix is mapped as type _float_. When  
performing a sort against this field, it does something very weird.. one  
example, see the resulted sort value..:

// Query - all records newer than 5 minutes ago  
{  
"size" : 1000,  
"fields" : ["tstamp\_unix", "tstamp"],  
"sort": [  
{ "tstamp\_unix" : {"order" : "desc"} }  
],  
"query" : {  
"filtered": {  
"query": {  
"range": {  
"tstamp\_unix":{  
"gt": 1404895819  
}  
}  
},  
"filter": {  
"term": { "grouped\_identifier": "some\_value" }  
}  
}  
}  
}

// Result  
{  
"\_index" : "index",  
"\_type" : "type",  
"\_id" : "XYqXjRHPR4m8ndYKyp5-8Q",  
"\_score" : null,  
"fields" : {  
"tstamp\_unix" : ["1404896082.123818"],  
"tstamp" : ["2014-07-09 08:54:42.123818"]  
},  
"sort" : [1.40489613E9]  
}

Can't find any other resources on this.. any ideas??

--  
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/e6bea892-8c58-4b86-aef8-efee01998655%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e6bea892-8c58-4b86-aef8-efee01998655%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:17am UTC](https://discuss.elastic.co/t/date-formatting-issue-sorting-by-float/18552/2 "2017-07-06T01:17:03Z")

</div>


