# Is sorting possible on search\_as\_you\_type field

**URL:** <https://discuss.elastic.co/t/is-sorting-possible-on-search-as-you-type-field/276449>\
**Category:** Elasticsearch\
**Created:** [June 20, 2021, 5:18am UTC](https://discuss.elastic.co/t/is-sorting-possible-on-search-as-you-type-field/276449 "2021-06-20T05:18:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kiko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kiko/32/89385_2.png) [@kiko](https://discuss.elastic.co/u/kiko)\
**Post date:** [June 20, 2021, 5:18am UTC](https://discuss.elastic.co/t/is-sorting-possible-on-search-as-you-type-field/276449/1 "2021-06-20T05:18:59Z")

</div>

I have mapped my product/category titles to search\_as\_you\_type fields. When I try to sort by those fields I get this error:

```auto
"error": {

        "root_cause": [

            {

                "type": "illegal_argument_exception",

                "reason": "Fielddata is not supported on field [name] of type [search_as_you_type]"

            }

        ],

```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 20, 2021, 6:23am UTC](https://discuss.elastic.co/t/is-sorting-possible-on-search-as-you-type-field/276449/2 "2021-06-20T06:23:50Z")

</div>

You can't sort on such a filed.  
You need to define a subfield of type `keyword` and sort on that one.

---

<div class="post-metadata">

**Author:** ![kiko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kiko/32/89385_2.png) [@kiko](https://discuss.elastic.co/u/kiko)\
**Post date:** [June 20, 2021, 6:43am UTC](https://discuss.elastic.co/t/is-sorting-possible-on-search-as-you-type-field/276449/3 "2021-06-20T06:43:58Z")

</div>

I tried creating a keyword subfield of search\_as\_you\_type field but it would not stick, then I found a Github issue which proposes creating a text field with two subfields(search\_as\_you\_type and keyword) and that seems to go with ES.  
So this is my workaround for now, thanks.

---

<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 18, 2021, 6:44am UTC](https://discuss.elastic.co/t/is-sorting-possible-on-search-as-you-type-field/276449/4 "2021-07-18T06:44:55Z")

</div>

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