# Search UI sorting by date: No mapping found error

**URL:** <https://discuss.elastic.co/t/search-ui-sorting-by-date-no-mapping-found-error/291857>\
**Category:** Elasticsearch\
**Created:** [December 14, 2021, 6:36pm UTC](https://discuss.elastic.co/t/search-ui-sorting-by-date-no-mapping-found-error/291857 "2021-12-14T18:36:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![asorondo](https://avatars.discourse-cdn.com/v4/letter/a/77aa72/32.png) [@asorondo](https://discuss.elastic.co/u/asorondo)\
**Post date:** [December 14, 2021, 6:36pm UTC](https://discuss.elastic.co/t/search-ui-sorting-by-date-no-mapping-found-error/291857/1 "2021-12-14T18:36:41Z")

</div>

Hi!

I'm using Elasticsearch and search UI and wish to sort by different fields.

I'm using the search UI component "Sorting" as follows:

```auto
<Sorting
                      label={"Sort by"} 
                      sortOptions={[
                        {
                          name: "Relevance",
                          value: "",
                          direction: ""
                        },
                        {
                          name: "Total",
                          value: "total",
                          direction: "asc"
                        },
                        {
                          name: "Duration",
                          value: "duration",
                          direction: "asc"
                        },
                        {
                          name: "Date",
                          value: "date",
                          direction: "asc"
                        }
                      ]}
                    />

```

For Relevance, Total and Duration I get the correct results when selecting the sorting option on the UI but when selecting the Date option I get the error: "No mapping found for [date.keyword] in order to sort on".

The four fields were declared in the same way and all the results have a Date field, maybe it's a date format issue?

I also tried to do it manually by using withSearch and the setSort option but couldn't make it work and didn't find an example of how it should be used.

```auto
this.setSort({
       sortField: "date",
       sortDirection: "asc",
})

```

Can someone help me figure out how to fix this issue?  
Thank you very much in advance!

---

<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:** [January 11, 2022, 6:37pm UTC](https://discuss.elastic.co/t/search-ui-sorting-by-date-no-mapping-found-error/291857/2 "2022-01-11T18:37:05Z")

</div>

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