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:
- N-Gram Token filter with "min_gram=1" and "max_gram=3".
- 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!