# Error sorting on date field

**URL:** <https://discuss.elastic.co/t/error-sorting-on-date-field/1527>\
**Category:** Elasticsearch\
**Created:** [May 29, 2015, 12:04am UTC](https://discuss.elastic.co/t/error-sorting-on-date-field/1527 "2015-05-29T00:04:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pavanbnv](https://avatars.discourse-cdn.com/v4/letter/p/958977/32.png) [@pavanbnv](https://discuss.elastic.co/u/pavanbnv)\
**Post date:** [May 29, 2015, 12:04am UTC](https://discuss.elastic.co/t/error-sorting-on-date-field/1527/1 "2015-05-29T00:04:33Z")

</div>

Hi All,

I am getting an error while sorting on date and retrieving records from my index. The shards are failed and the reason mentioned is "PagedBytesIndexFieldData cannot be cast to Atomic Numeric Field Data".

My mapping is

"date" : {  
type : "date"  
format : "yyyy-MM-dd HH:mm:ss.SSS"  
}  
Any suggestions please

---

<div class="post-metadata">

**Author:** ![Jason\_Wee](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@Jason\_Wee](https://discuss.elastic.co/u/Jason_Wee)\
**Post date:** [May 29, 2015, 12:33pm UTC](https://discuss.elastic.co/t/error-sorting-on-date-field/1527/2 "2015-05-29T12:33:23Z")

</div>

well, i try to reproduce based on your description.

```
$ curl -XGET 'http://localhost:9200/my_index/_mapping?pretty'
{
  "my_index" : {
    "mappings" : {
      "my_type" : {
        "properties" : {
          "date" : {
            "type" : "date",
            "format" : "yyyy-MM-dd HH:mm:ss.SSS"
          },
          "title" : {
            "type" : "string"
          }
        }
      }
    }
  }
}

```

and then do the sort

> {  
> "took" : 19,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 3,  
> "max\_score" : null,  
> "hits" : [ {  
> "\_index" : "my\_index",  
> "\_type" : "my\_type",  
> "\_id" : "2",  
> "\_score" : null,  
> "\_source":{ "title": "660 6th street", "date": "2015-05-29 20:19:18.456" },  
> "sort" : [1432930758456]  
> }, {  
> "\_index" : "my\_index",  
> "\_type" : "my\_type",  
> "\_id" : "1",  
> "\_score" : null,  
> "\_source":{ "title": "110 5th Avenue", "date": "2015-05-29 20:19:18.123" },  
> "sort" : [1432930758123]  
> }, {  
> "\_index" : "my\_index",  
> "\_type" : "my\_type",  
> "\_id" : "3",  
> "\_score" : null,  
> "\_source":{ "title": "Sue never goes anywhere without her alligator skin purse", "date": "2015-05-29 20:19:17.456" },  
> "sort" : [1432930757456]  
> } ]  
> }  
> }

there is no exception like you mentioned.

can you give more information like what es are you using? what java version are you using? a few sample of your data and the query you executed such that it gave that exception.

jason

---

<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:10am UTC](https://discuss.elastic.co/t/error-sorting-on-date-field/1527/3 "2017-07-06T00:10:51Z")

</div>


