SearchWP

Version 4 Documentation

Partial Matches, Fuzzy Matches, Spelling Corrections

When partial matching is enabled, SearchWP will attempt to find partial matches for search terms. Partial matching logic has been implemented in multiple, subsequent levels. This article will explain the internal logic of SearchWP’s partial matching implementation.

Level 1: LIKE

The first level of partial matches is a standard LIKE partial match, where search terms will be used as partial string matches for other content in your search index. You can customize whether prefix or suffix partial matching is implemented using the available hooks, by default only suffix partial matching is applied.

Example: Searching for ball will include results for balloon but not baseball

Depending on your site content, you can customize whether prefix or suffix matching is skipped with the following hooks:

Any resulting partial matches at this stage will be returned and SearchWP will include them when finding search results. If results are found, partial matching is concluded at this point by default.

Level 2: Fuzzy matching

If LIKE partial matches are not found, SearchWP will then continue seeking partial matches by implementing rudimentary fuzzy matching. Fuzzy matching will take into account slight spelling issues by scanning the index for terms that linguistically sound like the search terms.

For example, fuzzy matching will find results for soccer when searching for socker because of the linguistic similarity.

Alternatively, fuzzy matching will not find results for soccer when searching for sckr as some other fuzzy matching algorithms operate. This is because the linguistic difference is too far apart. You have control over the threshold of how closely aligned terms need to be to be considered a fuzzy match:

NOTE: As this threshold is reduced, there is an increased likelihood that unexpected/unwanted fuzzy matches are returned.

Fuzzy matching is used as a last resort when partial matches have been enabled in SearchWP, after LIKE matches have not been found. You do have the option of forcing fuzzy matches to be included in results despite LIKE matches having been found:

Please use these hooks with caution as they can have a drastic effect on the relevance of returned results. Before relying heavily on partial matches it is suggested that Synonyms are used instead.