In the example, we only run this suggest query when no results are returned from the search query. We can now filter out options based on collate_match. For most cases, a sensible analyzer would be set up like this:Įnter fullscreen mode Exit fullscreen mode It can use the shingled representation of the data to determine how common the corrected words appear next to each other.ĭepending on how you configure the shingle filter, the suggester will be able to suggest shorter or longer sentences. To take the context into account, the Phrase Suggester uses a shingled version of the specified field to be able to suggest combinations of terms correctly. If a user now searches for "harry poter", you do know which suggestion to give: "Potter". Without context, you don't know which one is better though. If a user now searches for "poter", you could correct that to either "Potter" or "poster". The Phrase Suggester will then combine these suggestions in a smart way into a single correction for the whole input.įor example, imagine you have a document with the text "Harry Potter poster". Each of these generators will generate suggestions for a single term. To get the Phrase Suggester to work, we'll need to supply it with a list of generators. Today we are going to use the Phrase Suggester to find search terms that are related to some input search terms. Users are likely to be at least annoyed when presented with no results, and in many cases they might give up their search for something completely.Įlasticsearch provides an extensive suggest feature which allows you to autocomplete user input. This hurts the user directly, as they will either need to fix their search term, or will think that the item they are looking for simply is not available. The worst thing you can do is show no results when you actually have some idea of what results to show. If you want to try it out yourself, check out this example repo. This post shows you how to find corrected search terms in Elasticsearch using the suggester query type, and how to apply this in an effective way. Only so much can be solved by optimizing the matching of your search query. You probably know how Google handles these situations: The search engine suggests a corrected search term, or even automatically corrects the terms you searched for if nothing could be found.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |