# Sorting by date\_range

**URL:** <https://discuss.elastic.co/t/sorting-by-date-range/150521>\
**Category:** Elasticsearch\
**Created:** [October 1, 2018, 7:24am UTC](https://discuss.elastic.co/t/sorting-by-date-range/150521 "2018-10-01T07:24:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lbugar](https://avatars.discourse-cdn.com/v4/letter/l/6f9a4e/32.png) [@lbugar](https://discuss.elastic.co/u/lbugar)\
**Post date:** [October 1, 2018, 7:24am UTC](https://discuss.elastic.co/t/sorting-by-date-range/150521/1 "2018-10-01T07:24:14Z")

</div>

Is it possible to sort by "date\_range" field?  
If yes, how?

Mapping:

```
PUT testindex
{
  "mappings": {
    "datetest": {
      "properties": {
        "created": {
          "type": "date"
        },
        "id": {
          "type": "keyword"
        },
        "Name": {
          "type": "keyword"
        },
        "dater": {
					"type": "date_range"
				}      
      }  
    }
  }
}

```

query:

```
GET /testindex/_search
{
 "query": {
    "match_all": {}
  },
  "sort": [
    {
      "dater": {
        "order": "desc"
      }
    }
  ]
}

```

result:

```
    error": {
        "root_cause": [
          {
            "type": "illegal_argument_exception",
            "reason": "Fielddata is not supported on field [dater] of type [date_range]"
          }
        ]
    }

```

thank you very much

---

<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:** [October 29, 2018, 7:24am UTC](https://discuss.elastic.co/t/sorting-by-date-range/150521/2 "2018-10-29T07:24:16Z")

</div>

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