# Problem applying sort on ngram field

**URL:** <https://discuss.elastic.co/t/problem-applying-sort-on-ngram-field/14193>\
**Category:** Elasticsearch\
**Created:** [October 31, 2013, 4:46pm UTC](https://discuss.elastic.co/t/problem-applying-sort-on-ngram-field/14193 "2013-10-31T16:46:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julien\_Ripault](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/julien_ripault/32/2009_2.png) [@Julien\_Ripault](https://discuss.elastic.co/u/Julien_Ripault)\
**Post date:** [October 31, 2013, 4:46pm UTC](https://discuss.elastic.co/t/problem-applying-sort-on-ngram-field/14193/1 "2013-10-31T16:46:42Z")

</div>

Hi,

I have encountered a little problem while using sort in a query, I explain.  
I index some documents with a string field "label" indexed in a multi field  
(one not analyzed and one indexed with n-gram min to 3). I put some  
documents in the index including one with a label value length of 3  
characters like 'abc'

I try a simple match\_all query with a sort on the field 'label', it works  
well, all the entries are there including the 'abc' one  
If I add a from and size to paginate the results, there is the right number  
of results but my entry 'abc' is never returned but other entries appear in  
duplicates.

I tried different mappings but it seems to be a combination of pagination,  
the sort, ngram and the fact that the value od the field sorted is equals  
to the min ngram

Maybe I have missed something

Thanks

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:09am UTC](https://discuss.elastic.co/t/problem-applying-sort-on-ngram-field/14193/2 "2017-07-06T02:09:34Z")

</div>

Closed on July 6, 2017, 2:09am UTC


