# Phrase suggester with trigrams - Did you mean

**URL:** <https://discuss.elastic.co/t/phrase-suggester-with-trigrams-did-you-mean/105044>\
**Category:** Elasticsearch\
**Created:** [October 24, 2017, 10:53am UTC](https://discuss.elastic.co/t/phrase-suggester-with-trigrams-did-you-mean/105044 "2017-10-24T10:53:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![xserrat](https://avatars.discourse-cdn.com/v4/letter/x/df705f/32.png) [@xserrat](https://discuss.elastic.co/u/xserrat)\
**Post date:** [October 24, 2017, 10:53am UTC](https://discuss.elastic.co/t/phrase-suggester-with-trigrams-did-you-mean/105044/1 "2017-10-24T10:53:18Z")

</div>

Hi everyone!

I'm trying to make suggests using a Phrase suggest to obtain a _Did you mean_ feature.

I would like to use a combination of "tokenizer+token filters" to get the properly results.

I have for example the word "buy" and I would like to obtain the trigram " **b _bu buy uy_ y**". In order to do it I found the following:

1. N-Gram Token filter with "min\_gram=1" and "max\_gram=3".
2. Custom analyzer using previous filter and another filter for lowercase.

{  
"filter": {  
"trigram\_filter": {  
"type": "ngram",  
"min\_gram": 1,  
"max\_gram": 3  
}  
},  
"analyzer": {  
"type": "custom",  
"tokenizer": "standard",  
"filter": [  
"lowercase",  
"trigram\_filter"  
]  
}  
}

Then, I obtain: "b,bu,buy,u,uy,y". How could I modify the grams building in order to obtain my requested result: " **b _bu buy uy_ y**" ?

**RESOLVED!**

Setting "prefix\_length" property to 0 I obtain the best results because elastic tries to find the suggest name by changing the first letter instead of another one (default behaviour).

I hope it helps!

Thank you so much!

---

<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 21, 2017, 10:53am UTC](https://discuss.elastic.co/t/phrase-suggester-with-trigrams-did-you-mean/105044/2 "2017-11-21T10:53:41Z")

</div>

Closed on November 21, 2017, 10:53am UTC

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