That was all about our third approach for implementing auto-complete in ES. Both the queries in example below return "Goblet of Fire" as suggestions -Īs it can be observed in the response above, only "Harry Potter and the Prisoner of Azkaban" from the "crime" genre is returned even though the passed prefix matches both the documents indexed above. You can also specify prefix text as regex query. You can manually tokenize your input string and pass the tokens to Elasticsearch in the input option, like how we have done in the examples above by providing "Goblet of Fire" as additional input.Ĭompletion suggester supports fuzzy queries that allow us to consider typos while searching documents. You can, however, use the input option to provide multiple matches.
if you have a movie named "Harry Potter and the Goblet of Fire" and you type in "goblet of fire", it won't return the document as a match. So, it won't be able to match in the middle of the input like n-gram based approaches. As discussed above, it preserves the order of input in FST. In case of completion suggester, ES matches the documents one character at a time starting from the first character, moving ahead one position as a new character is typed in. This can be avoided by using skip_duplicates option. "Goblet of Fire" is returned twice in suggestions as we had provided this text as input in both the documents.
Enter fullscreen mode Exit fullscreen mode