More about automatic misspelling correction feature ( fuzzy search ).
Advanced Woo Search plugin has built-in feature to automatically fix typos/misspellings inside search queries.
Example: shop have a product Hoodie with Zipper
. User makes a typo in the search query and searches for ziper
instead of zipper
. In this case he will still see the correct search result thanks to automatic misspelling correction.
Misspelling autocorrection is enabled by default. So there is no need for any extra steps.
Additionally, if for some reason you need to disable it, you can do this from the plugin settings page. Just open it and find Misspelling fix
option.
Important note to be mentioned - misspelling fix applied only if the current search query returns no results. If a user makes a typo, but your shop also has a product with such a typo in the word - this product will be shown in the search results and no auto correction will be applied.
Fuzzy search is working even with several typos inside one word:
Example: user type cardrige
instead of cartridge
. Plugin will still find a product with word cartridge
inside.
Technically misspelling auto correction is working in the following way: plugin compares word from search query with words inside index table. It detects how similar each of these words are.
Similarity is checked with Levenshtein distance - this value shows how many single-character edits (insertions, deletions, or substitutions) have to be made in the word to make these 2 words the same. Less value refers to the great similarity of the words.
If you need to change some default parameters of the algorithm ( for example - limit autocorrection only to 1 edit ) - this can be done via aws_fuzzy_params
filter.
Here are its default values that can be changed:
min_terms_length
= 3 - apply misspelling fix only for words with length >= N
max_similar_terms
= 50 - maximal number of similar words that can be found
min_distance
= 2 - minimal allowed Levenshtein distance for fixed words
Example: we want to allow misspelling fix only for words with 1 typo. This means that we need to change min_distance
value to 1
. Code snippet for such a change will look like that:
apply_filters( 'aws_fuzzy_params', 'my_aws_fuzzy_params' ); function my_aws_fuzzy_params( $fuzzy_params ) { $fuzzy_params['min_distance'] = 1; return $fuzzy_params; }