Fuzzy search
Fuzzy search
Lucene includes functionality for performing fuzzy searches. A fuzzy search searches for terms that are similar but not exactly equal to the terms specified by the user. Elastic Path uses fuzzy search functionality to look for possible results when no exact matches are found.
Fuzzy searches
Fuzzy search uses the Search Settings system setting.
The minimum similarity value is a value between 0 and 1 that sets the required similarity between the query term and the matching terms. For example, if COMMERCE/SEARCH/minimumSimilarity is set to 0.5, a term of the same length as the query term is considered similar to the query term if the edit distance between both terms is less than length(term)*0.5, where edit distance is a measure of similarity between two strings and distance is measured as the number of character deletions, insertions, or substitutions required to transform one string to the other string.
For example, the edit distance between "kitten" and "sitting" is 3, since these three edits change one into the other, and there is no way to do it with fewer than three edits:
- kitten ? sitten (substitution of 'k' for 's')
- sitten ? sittin (substitution of 'e' for 'i')
- sittin ? sitting (insert 'g' at the end)
Key classes and files
- SolrIndexSearcher - A data access object for Lucene searching. This class contains logic for executing fuzzy searches when no exact matches are found.
- ProductQueryComposer - Implements a method, composeFuzzyQuery(..), that creates a new FuzzyQuery Lucene object. The object is populated with the search terms and configuration options specified in the search settings.