How to disable fuzziness

As explained in this article:

Depending on how your users search, you may or may not want fuzzy matching enabled. While fuzzy matching seems like a great feature (and it can be), it can create a situation where there are many, many items at the end of your search results that are loosely, if at all, related to the search query. Consider, for example, this (partial) list of matches for the search term dogs with a fuzziness value of 1: dog, does, cogs, hogs, logs, pogs, digs. A lot of those words aren’t even remotely related to the term dogs, but they’ll appear (later) in your search results, or even right on the top if your site doesn’t actually have anything related to the word(s) searched for.

You can disable fuzziness (the resiliency to typos) by adding the following snippet to your codebase — more on how to do that in our Enhancing ElasticPress with Custom Functions article.

PHP
add_filter( 'ep_post_match_fuzziness', '__return_zero' );

You might need a different snippet if you use a different search algorithm. While using the search algorithm used before ElasticPress 3.5 (named default) you’ll need this line of code:

PHP
add_filter( 'ep_post_fuzziness_arg', '__return_zero', 20 );