# Can we sort on analyzed string

**URL:** <https://discuss.elastic.co/t/can-we-sort-on-analyzed-string/8278>\
**Category:** Elasticsearch\
**Created:** [July 2, 2012, 6:21am UTC](https://discuss.elastic.co/t/can-we-sort-on-analyzed-string/8278 "2012-07-02T06:21:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhishek\_Jajoria](https://avatars.discourse-cdn.com/v4/letter/a/b5e925/32.png) [@Abhishek\_Jajoria](https://discuss.elastic.co/u/Abhishek_Jajoria)\
**Post date:** [July 2, 2012, 6:21am UTC](https://discuss.elastic.co/t/can-we-sort-on-analyzed-string/8278/1 "2012-07-02T06:21:38Z")

</div>

I just want to know can we sort a string alphabetically if it is analyzed .

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [July 2, 2012, 8:21am UTC](https://discuss.elastic.co/t/can-we-sort-on-analyzed-string/8278/2 "2012-07-02T08:21:34Z")

</div>

On Mon, 2012-07-02 at 11:51 +0530, jajoria abhishek wrote:

> I just want to know can we sort a string alphabetically if it is  
> analyzed .

No. You can't sort on a field that has multiple values, and an analyzed  
string has multiple tokens.

Instead, you can use multi\_fields to have two versions of the same  
field: one analyzed, and one not analyzed (to be used for sorting)

clint

---

<div class="post-metadata">

**Author:** ![svepw24](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@svepw24](https://discuss.elastic.co/u/svepw24)\
**Post date:** [June 27, 2017, 9:03am UTC](https://discuss.elastic.co/t/can-we-sort-on-analyzed-string/8278/3 "2017-06-27T09:03:14Z")

</div>

But sorting on a field type=keyword does not result in an alphabetic order (in german language we have ä,ö,ü). The only way I found out to result in an alphabetic order, is to mark the field analyzer=german, fielddata=true which takes a lot of memory from the heap.  
Any ideas to avoid fielddata for correct alphabetical sorting in german language ?

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [June 27, 2017, 10:28pm UTC](https://discuss.elastic.co/t/can-we-sort-on-analyzed-string/8278/4 "2017-06-27T22:28:42Z")

</div>

Sorting on strings uses unicode codepoint order. To customize this for German, you probably want to use the icu plugin. See [https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis-icu-collation.html](https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis-icu-collation.html).

---

<div class="post-metadata">

**Author:** ![qwerty2002](https://avatars.discourse-cdn.com/v4/letter/q/ed655f/32.png) [@qwerty2002](https://discuss.elastic.co/u/qwerty2002)\
**Post date:** [June 28, 2017, 3:24am UTC](https://discuss.elastic.co/t/can-we-sort-on-analyzed-string/8278/5 "2017-06-28T03:24:12Z")

</div>

:การยิ้มกว้าง:

---

<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:** [November 4, 2022, 4:01am UTC](https://discuss.elastic.co/t/can-we-sort-on-analyzed-string/8278/6 "2022-11-04T04:01:24Z")

</div>


