# Get direct hit first using fuzzy query in autocompletion suggester

**URL:** <https://discuss.elastic.co/t/get-direct-hit-first-using-fuzzy-query-in-autocompletion-suggester/106201>\
**Category:** Elasticsearch\
**Created:** [November 2, 2017, 1:03pm UTC](https://discuss.elastic.co/t/get-direct-hit-first-using-fuzzy-query-in-autocompletion-suggester/106201 "2017-11-02T13:03:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Varsha\_Rao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varsha_rao/32/23727_2.png) [@Varsha\_Rao](https://discuss.elastic.co/u/Varsha_Rao)\
**Post date:** [November 2, 2017, 1:03pm UTC](https://discuss.elastic.co/t/get-direct-hit-first-using-fuzzy-query-in-autocompletion-suggester/106201/1 "2017-11-02T13:03:09Z")

</div>

I'm using Elasticsearch to provide auto suggestions to names in a database, and I want it to be fuzzy to allow for minor spelling errors. Now I have two names that sound similar, JohnA and JohnB indexed. This is my query:  
{  
"suggest": {  
"suggest": {  
"completion": {  
"fuzzy": {  
"fuzziness":"auto  
},  
"field": "suggest",  
"size": 5  
},  
"prefix": "JohnB"  
}  
}  
}

The result set contains JohnA before JohnB. Ideally I would want JohnB to appear before JohnA . How can I achieve this while still using fuzziness in the suggest query.

---

<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 30, 2017, 1:03pm UTC](https://discuss.elastic.co/t/get-direct-hit-first-using-fuzzy-query-in-autocompletion-suggester/106201/2 "2017-11-30T13:03:10Z")

</div>

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