# Search after and icu collation how to convert string to sort value

**URL:** <https://discuss.elastic.co/t/search-after-and-icu-collation-how-to-convert-string-to-sort-value/104017>\
**Category:** Elasticsearch\
**Created:** [October 15, 2017, 8:10am UTC](https://discuss.elastic.co/t/search-after-and-icu-collation-how-to-convert-string-to-sort-value/104017 "2017-10-15T08:10:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexey\_Melnikov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexey_melnikov/32/23060_2.png) [@Alexey\_Melnikov](https://discuss.elastic.co/u/Alexey_Melnikov)\
**Post date:** [October 15, 2017, 8:10am UTC](https://discuss.elastic.co/t/search-after-and-icu-collation-how-to-convert-string-to-sort-value/104017/1 "2017-10-15T08:10:53Z")

</div>

Good day.

I have a big index with 10 million records and for pagination I'm using searchAfter property from query with some sorting. Sorting is done on a field with type 'icu\_collation\_keyword'  
It works very fine.

But sometimes I need to scroll to some random document in the middle and I need to load documents after it.  
But I cannot do that, because ES waits for values like this: "ᒨ䳏攦匐ࡘݰ᐀ \u0001".

So the question is, I have a document and I have field value used for sorting, but I cannot pass it into searchAfter because it waits sort value in a different format. Maybe I can convert somehow field value in Java client or maybe I can somehow retrieve that value with document from index?

ES version 5.6

---

<div class="post-metadata">

**Author:** ![Alexey\_Melnikov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexey_melnikov/32/23060_2.png) [@Alexey\_Melnikov](https://discuss.elastic.co/u/Alexey_Melnikov)\
**Post date:** [October 16, 2017, 12:05pm UTC](https://discuss.elastic.co/t/search-after-and-icu-collation-how-to-convert-string-to-sort-value/104017/2 "2017-10-16T12:05:45Z")

</div>

I figured out how to do it.

I executed a search query with condition to id of document and required sorting.  
With that query I'm getting one SearchHit with sortValue formatted for ICU collation. So I can use it for further search.

It's weird, but this only one option I found how to get this value. And I'm still thinking ES should convert or normalize searchAfter values. It will allow to write code without extra calls.

---

<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 13, 2017, 12:06pm UTC](https://discuss.elastic.co/t/search-after-and-icu-collation-how-to-convert-string-to-sort-value/104017/3 "2017-11-13T12:06:36Z")

</div>

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