GET FREE VERSION GET THE PRO VERSION

Misspelling fix

More about automatic misspelling correction feature ( fuzzy search ).

In this article

Overview

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.

Example of misspelling feature

Example of misspelling feature

Search and misspelling fix

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.

Misspelling option

Misspelling option

There are some additional values available for this option that we will cover in the next chapter.

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.

Misspelling fix for word with several typos

Misspelling fix for word with several typos

Available misspelling options

As was mentioned before - you can enable/disable misspelling feature via Misspelling fix option.

Misspelling option

Misspelling option

So there are several values that you can choose from. In general you choose from enabling or disabling misspelling features for users search. Additionally for both variants you can show the list of fixed terms that was generated after applying the misspelling fix algorithm.

So below we will cover possible values of Misspelling fix option.

On. Automatically search for fixed terms.

If the current search query does not give results - try to correct typos in the search words. If the query is processed - search by fixed terms and return results. The end user will not see any difference compared to the standard search mechanics.

Search with automatic misspelling fix

Search with automatic misspelling fix

On. Additionally show text "Showing results for ..." with a list of fixed terms at the top of search results.

Same as in the first case, but additionally the text "Showing results for ..." is displayed with a list of corrected terms that was generated using typo correction algorithms.

Search with automatic misspelling fix and text at the top

Search with automatic misspelling fix and text at the top

Off. Totally disable misspelling fix.

Fully disable misspelling fix. If a user's search query contains any typos - they won't be fixed.

Misspelling fix is totally disabled

Misspelling fix is totally disabled

Off. Instead show text "Did you mean ..." with a clickable list of fixed terms at the top of search results.

Misspelling fix is disabled. But if the search query does not give results - try to correct typos in search terms, and if it succeeds - show the text "Did you mean ..." with the list of corrected terms at the top of the search results list. The list of terms is interactive - the user can click on any term and make the plugin search for that particular term.

Misspelling fix is disabled. Instead the user can see a list of corrected terms

Misspelling fix is disabled. Instead the user can see a list of corrected terms

Changing default misspelling parameters

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

allow_numeric = false - allow or not misspell fix for numeric search terms

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;
}

Numeric search terms

By default the plugin won't try to fix numeric search terms. This means that search query 112233 won't show a product with SKU 112234 and so on.

Want to change this? Just use the following code snippet to allow correction for numeric strings.

add_filter( 'aws_fuzzy_params', 'my_aws_fuzzy_params' );
function my_aws_fuzzy_params( $fuzzy_params ) {
    $fuzzy_params['allow_numeric'] = true;
    return $fuzzy_params;
}