In the search systems like search engines, users enter a search query, and the search engine returns some results based on the user's query. The two approaches for finding the web pages are the following:
Exact matching: Find and return the webpages where the search query exactly matches the content on the webpage.
Approximate matching: Find and return the webpages where the search query approximately matches the content on the webpage.
A fuzzy search returns results that are based on an approximate match of the search term with the data we're looking for. It's used in search systems to make searching flexible, and it also acts as a spelling corrector.
In fuzzy search, the actual query is modified using different operations like insertion, deletion, substitution, and transposition, as shown in the following illustration:
Above, we saw one example for each operation, but there would be multiple options (strings) that would pop up by altering a single query. We have to find the closest string. The closeness of a query with any other string is measured by the number of operations performed on the search query to convert it into that specific string. Let's look into some examples shown in the below table:
If a user enters a random query like "jsavsbnavg", the fuzzy search will first find the possible words that can be made from this query by applying the above operations. Two of the words that are made through deletion operations are "java" and "svg". To convert "jsavsbnavg" into "java", six delete operations are performed.
Different algorithms are used by fuzzy search systems to find the distance of the query from other matching strings. Some of these algorithms are discussed here.