![]() ![]() The data in this example is derived from data collected by the Movie Tweetings project between 20. Solr’s suggesters return the entire field for a match, making it possible to suggest whole titles or phrases based on just the first few letters. The underlying mechanics of an FST allow for near-matches on the input, which means that auto-suggest will work even when the inputs contain typos or misspellings. FST stands for “Finite-State Transducer”. This is easy to do using Solr’s FST-based suggesters. This post shows how to add a Solr suggester component to a Fusion query pipeline in order to provide the kind of auto-complete functionality expected from a modern search app.īy auto-complete we mean the familiar set of drop-downs under a search box which suggest likely words or phrases as you type. Luckily, But we can go a different way by expanding Solr’s functionality a bit.įirst, we need to create word-based suffixes for phrases in the index.The Solr suggester search component was previously discussed on this blog in the post Solr Suggester by Solr committer Erick Erickson. Additionally, the reverse wildcard technique shouldn’t be applied to this use case because we have wildcards on both ends, making the query even slower. The problem with applying this solution is that Solr will have to execute a full term scan to check for every term that is a possible match, rendering the query very slow. One solution is to amend our first use case by adding a leading wildcard to the query: Whereas, prediction wouldn’t occur in these cases: This means “my little pony” would appear when the user types: Match as a suggestion everything that contains the user’s phrase as a subphrase. In this this last case, our requirement now is: Implementing multiterm ordered suggestions with Solr The same edge n-gram technique mentioned above can be applied on a single-word basis, with prefixes for each individual word stored as well. The user’s phrase also needs to be parsed into a set of words: Setting up the query to behave in this way isn’t hard: it requires every phrase to be split in the index. Whereas, prediction should not occur when the user types: The phrase, “my little pony” should now appear when the user types: In this case, assume that our requirement changed to: Implementing multiterm unordered suggestions with Solr This approach has an obvious benefit in that a query that is powered with a larger index is not only simpler but also performs faster, in general. Let’s take “my little pony,” with this configuration as an example: Īcceptable partial search phrases would be: It requires storing every prefix for a given phrase in the index. In this case, we need the search to take into account every phrase in our index, as well as every partial phrase the user types in as a single term, and use KeywordTokenizer for the suggestion field: Īn alternative to using a wildcard query is the edge n-gram approach. ![]() However, prediction will not occur when the user types: If we have the “ my little pony” phrase in our index, it should show when the user types: Match as a suggest everything that starts exactly with the phrase _ Implementing single term suggestions with Solr Solr supports all three of these approaches via field type, which defines how data in a given field is interpreted and queried. The third method matches everything that contains a subphrase of the complete phrase as long as it’s in the correct order, i.e. This autocomplete method recognizes “shirts” as part of the phrase, like “men’s shirts,” and suggests it to the customer along with “women’s shirts,” “work shirts,” and other phrases that contain “men’s.” This method looks for the first letter, then the first word in a phrase, a search for “men’s shirts” must begin with “m,” then “men’s,” to bring up “men’s shirts” as a response. Solr, an open-source framework that powers many of the world’s most popular e-commerce sites and applications, supports three approaches to auto-complete implementation: Whether Google, Amazon, or smaller sites and vendors, predictive typing, as it’s otherwise known, (also sometimes called auto-suggest, search-as-you-type or type-ahead) has become an expected part of an engaging, user-friendly search experience. ![]() In recent years, autocomplete has become a staple feature for searches of all types. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |