Fuzzy search

FiboSearch Pro uses fuzzy search to find matching products, even if the user makes a typo, eg. types ‘iphome’ instead of ‘iphone’.

Note: this feature works only for products, posts, and pages. It does not work for taxonomies: categories, tags, brands, etc.

This is how the algorithm works:

FiboSearch uses 3 variables for fuzzy searching. These are their default values:
prefixLength = 2
maxExpansions = 200
distance = 2

  1. Let’s assume that the user types the word “laptip”. This word does not match any product, page or post, so FiboSearch Pro tries to guess what the user meant.
  2. The word is cut to prefixLength letters (it’s 2 letters in our case), which leaves the word “la”.
  3. FiboSearch searches for words that begin with “la”. If there are many words, only maxExpansions of them are returned (200 in our example). Let’s assume that there are 5 words beginning with “la”: “laptop”, “lamp”, “lab”, “label” and “large”.
  4. Each of these words is checked for its similarity with “laptip” – the algorithm checks how many single-character edits (insertions, deletions, or substitutions) have to be made in the word to make the 2 words the same. This number of edits is called the Levenshtein distance (https://en.wikipedia.org/wiki/Levenshtein_distance).
  5. If the Levenshtein distance for a word is less than or equal to distance, then the word is included in the search process. These are the Levenshtein distances in our example:
    laptop vs laptip: 1 (needs 1 edit)
    lamp vs laptip: 3
    lab vs laptip: 4
    label vs laptip: 4
    large vs laptip: 4

    Here’s a website you can use to calculate the distance: https://phiresky.github.io/levenshtein-demo/.
  6. Only “laptop” with distance 1 (< 2) meets the criteria, and as a result, FiboSearch Pro will process the word “laptop” instead of “laptip”.

There are 4 options you can set for the Fuzzy Search feature on a settings page: disabled, soft mode, normal mode, and hard mode.

The variables for soft, normal, and hard fuzzy search are as follows:

Soft:
prefixLength = 2
maxExpansions = 50
distance = 1

Normal:
prefixLength = 2
maxExpansions = 200
distance = 2

Hard:
prefixLength = 2
maxExpansions = 400
distance = 3