⚠️ Note: This extension is DEPRECATED as of SearchWP version 3.0 and will be removed soon ⚠️
Fuzzy matching aims to make SearchWP a bit more lenient with search queries. Use this extension to include search terms that are close in spelling to terms within your index. There are some filters available for this Extension that let you fine-tune how loose the fuzziness is.
Note: Please read these notes before installing Fuzzy Matches
Using Fuzzy Matches is recommended only in circumstances that deem it necessary. This warning is given because Fuzzy Matches essentially reduces the effectiveness of SearchWP’s algorithm. Fuzzy Matches broadens search terms which can essentially bring in unwanted results.
It is recommended that you first monitor your actual search queries using SearchWP’s built-in statistics. Using this data you can evaluate what search terms are yielding zero results. The first step here would be to install Term Synonyms if these failed searches are due to common misspellings.
If there are too many common misspellings to make managing Term Synonyms feasible, then (and only then) would Fuzzy Matches be a recommended solution.
searchwp_fuzzy_min_length
Set the minimum word length to include in fuzzy matches (default is 5)
<?php | |
function my_fuzzy_word_length() | |
{ | |
return 5; | |
} | |
add_filter( 'searchwp_fuzzy_min_length', 'my_fuzzy_word_length' ); |
searchwp_fuzzy_threshold
Beyond basic fuzzy matching, SearchWP will apply some primitive spell checking to submitted terms. This filter lets you specify what minimum percentage should be used to constitute a valid match. Must be 0 – 100. (default is 80)
<?php | |
function my_fuzzy_threshold() | |
{ | |
return 85; | |
} | |
add_filter( 'searchwp_fuzzy_threshold', 'my_fuzzy_threshold' ); |
searchwp_fuzzy_digit_threshold
Set the maximum percentage of digits in search term to perform spell checking (default is 10)
<?php | |
function myChangeDigitThreshold() | |
{ | |
return 15; // 15% maximum threshold | |
} | |
add_filter( 'searchwp_fuzzy_digit_threshold', 'myChangeDigitThreshold' ); |
Changelog
1.4.4
- [Update] Updated updater
1.4.3
- [New] New filters
searchwp_fuzzy_prefix
andsearchwp_fuzzy_suffix
to refine control over partial matches - [Update] Updated author
- [Update] Updated updater
1.4.2
- [Fix] Fixed a regression that caused Fuzzy Matches' algorithm to fail in some cases
1.4
- [Improvement] Better term prep
- [Change] Adjusted priority for better interoperation with other SearchWP Extensions
1.3
- [Improvement] Support for automatic updates based on your SearchWP license key
1.2
- [Improvement] Don't find fuzzy matches if the search term exists
- [Change] Now requires at least SearchWP 2.4.11
1.1
- [Change] Use
searchwp_term_in filter
- [Change] Now requires at least SearchWP 2.0.3
1.0
- [Fix] Better match restriction
- [Fix] Fixed an issue with checking digit ratio
0.3
- Initial release