Fuzzy search represents a family of techniques that enable intelligent matching between search queries and content. At its core, it’s about finding relevant results even when the search terms don’t match perfectly. While most commonly used for handling misspellings and typos, this technology goes far beyond simple error correction - it can interpret ambiguous queries, understand informal language, handle partial words, and identify related concepts that might not share exact terminology.
The fuzzy matching techniques we’ll explore in this article allow Manticore Search to implement intelligent matching strategies that ensure comprehensive result retrieval. In this context, relevance becomes a nuanced art rather than a rigid science.
Understanding Search Relevance
The foundation of search lies in exact text matching, where queries are matched character-for-character against the indexed content. For instance, searching for “laptop” will return only records containing that exact word, not related terms like “notebook” or “computer”.
Exact matching serves many purposes well. With well-structured data, searching for “laptop” will surface all relevant records containing that term, whether in titles, descriptions, or categories. With enhanced data modeling, searching for “laptop” could even return related items like laptop accessories or computer services.
However, what happens when the exact term isn’t present in the records, despite the content being relevant? Synonyms can help here. But what if someone searches for “notebook” but types “notebok”? Without fuzzy matching, the search would yield no results.
Fuzzy matching enhances search relevance by making the experience more natural and forgiving. When implemented effectively, it seamlessly incorporates related items that would otherwise be missed. Like assembling a puzzle, fuzzy search gathers similar pieces to help users find exactly what they need. Moreover, since users often refine their needs during the search process, fuzzy matching presents options based on similarity, much like sampling dishes before choosing the perfect meal.
Modern search engines like Manticore Search, Elasticsearch, and Algolia offer sophisticated fuzzy matching capabilities, each with their unique approach. Let’s explore Manticore’s implementation in detail.
Understanding Fuzzy Search
What is Fuzzy Search?
Fuzzy search enables matching between words that aren’t identical. It handles various types of input variations, from simple typos to complex misspellings. This technology accommodates hurried typing, mobile users’ input challenges, and the complexities of spelling across different languages. It’s particularly valuable for matching user-generated content, which often contains variations in spelling and terminology. The technology can also incorporate phonetic matching capabilities.
Alternative terms include approximate string matching or fuzzy string matching.
Examples:
- Type “helo”, find records with “hello”
- Type “help”, find records with help and hello
See more examples & how this is implemented in Manticore below.
What is Fuzzy Matching?
Fuzzy matching broadens the concept to include finding information based on various types of similarities. We’ll focus on language-based similarities, including synonyms, grammatical variations (plurals, verb forms, etc.), dictionary-based approaches, and other linguistic or NLP techniques. We’ll also cover common search engine features like partial word matching, phrase matching, and filtering capabilities.
Examples:
- Type “pants”, find pants, trousers, slacks (synonyms)
- Type “be”, find Beatles, bees (prefix search)
See more examples & how this is implemented in Manticore below.
Other Applications of Fuzzy Logic
Fuzzy logic helps categorize items based on shared characteristics. For instance, a smartphone, tablet, and laptop share the characteristic of being portable computing devices, but smartphones and tablets are more closely related due to their touch interfaces and mobile operating systems.
Fuzzy logic builds relationships based on relative similarity rather than binary true/false conditions (objects match based on both being “portable” rather than having identical weights).
Implementing Fuzzy Search with Levenshtein Distance in Manticore
Error tolerance allows users to make mistakes while typing and still find relevant results. Manticore implements this through the Levenshtein distance algorithm.
What Constitutes a Typo?
- Missing characters: “laptp” → “laptop”
- Extra characters: “laptopp” → “laptop”
- Transposed characters: “lpatop” → “laptop”
- Wrong characters: “laptip” → “laptop”
The Levenshtein Distance Algorithm
Manticore’s error tolerance uses distance-based matching, implementing the Levenshtein distance algorithm. Distance measures the difference between a typed word and its exact match in the index. Specifically, it represents the minimum number of operations (adding, removing, replacing, or swapping characters) needed to transform one word into another. A perfect match has a distance of 0. When there’s an exact match or the distance is small (one or two character differences), the record is included in the results.
For example, if the engine receives “laptp”, it could match “laptop” (distance = 1 / one character missing), or “laptps” (distance = 2 / two operations needed).
Distance sets a tolerance threshold. In Manticore, you can configure this using the distance
parameter, defaulting to 2: words with a distance of 3 or more differences are excluded from results.
Examples of Fuzzy Search Using Levenshtein Distance
Here are examples of how Manticore calculates operations needed to match “iphone”:
- iphone - 0 differences (exact match)
- iphon - 1 difference (deletion: e)
- iphonee - 1 difference (addition: e)
- iphne - 1 difference (deletion: o)
- iphonne - 1 difference (addition: n)
- iphne - 2 differences (deletion: o, deletion: e)
- iphonne - 2 differences (addition: n, addition: e)
- iphne - 3 differences (deletion: o, deletion: e, deletion: n) - beyond default threshold
Result Ranking and Error Tolerance
Regarding relevance: all fuzzy matches based on spelling differences are considered less relevant than exact matches. Therefore, records with a distance of 0 – exact matches – are ranked higher than those with errors. Similarly, records with 1 error are ranked higher than those with 2 errors.
Keyboard Layout-Aware Fuzzy Search
A distinctive feature of Manticore’s fuzzy search is its keyboard layout awareness. This functionality understands that users might be typing with different keyboard layouts, leading to specific types of errors.
For example, if someone accidentally types with the wrong keyboard layout active, Manticore can interpret the query by considering physical key positions across different layouts. Manticore supports 17 different keyboard layouts including QWERTY, AZERTY, QWERTZ, and others, making it highly adaptable for international applications.
For instance, a user types “yucker” on a US keyboard, but the system interprets it as a German QWERTZ layout. Manticore recognizes the mismatch and correctly maps the input to “zucker” (the German word for “sugar”). Without layout awareness, the search would fail due to the Y/Z key swap. Manticore ensures users find results even if their keyboard layout is misconfigured.
Setting Up Fuzzy Search in Manticore
Implementing fuzzy search in Manticore is straightforward, with support for both SQL and JSON APIs.
Using SQL Syntax
SELECT * FROM mytable
WHERE MATCH('someting')
OPTION fuzzy=1, layouts='us,ua', distance=2;
In this example:
fuzzy=1
enables fuzzy matchinglayouts='us,ua'
specifies which keyboard layouts to consider (US and Ukrainian)distance=2
sets the maximum Levenshtein distance to 2
Using JSON API
POST /search
{
"table": "test",
"query": {
"bool": {
"must": [
{
"match": {
"*": "ghbdtn"
}
}
]
}
},
"options": {
"fuzzy": true,
"layouts": ["us", "ru"],
"distance": 2
}
}
This JSON example demonstrates how Manticore handles cross-layout typos—“ghbdtn” typed on a US keyboard would actually be “привет” (“hello” in Russian) if typed on a Russian keyboard.
Additional Fuzzy Matching Techniques
Partial Word Matching with Prefix Search
Like other advanced search engines, Manticore supports prefix matching for real-time search experiences. It enables the engine to match records based on partial words.
For example, records containing “apricot” are returned as soon as a user types “a”, “ap”, “apr”. There’s no need to wait for a complete word match before showing results.
Synonyms
Synonyms tell the engine which words and expressions to consider equivalent – for example, pants = trousers. Thus, a search for “trousers” will return “trousers” and “pants”, and a search for “pants” will also return “trousers” and “pants”.
While general thesaurus-based synonym expansion can be too broad, Manticore allows you to define specific, contextually relevant synonyms for your dataset using wordforms .
Optimizing Fuzzy Search for Best Results
While powerful, implementing fuzzy search requires careful consideration. It might return too many results or unexpected matches that could affect perceived relevance.
The search engine must manage this information expansion. For instance, by prioritizing exact matches, ensuring they appear at the top of results, above fuzzy matches:
- For misspellings, exact matches are considered more relevant than fuzzy matches (even if the error is obvious to the user).
- With synonyms, exact matches are more relevant than synonym matches (even if the query word has multiple meanings and the synonym would be more appropriate).
Manticore manages this by displaying fuzzy matches after exact matches. This is part of Manticore’s comprehensive approach to handling search variations.
There are also many UI patterns to manage this. For example, search engines often add “suggested spellings” just below the search bar. Or they offer Autocomplete or Query-Suggestion features, where the user is given suggested queries (and categories) in a dropdown list as they type, which they can choose from as their query. Manticore provides comprehensive support for these features as documented in our Autocomplete API .
But the ideal solution is the one below the surface, completely transparent to the user, where the search engine returns results that create an intuitive feeling in the user that the displayed items are the best and most relevant results – even if not exactly matching the text of the query.
Practical Applications
Let’s examine real-world scenarios where Manticore’s fuzzy search excels:
E-commerce
In e-commerce, users often search for products with complicated names or technical specifications they might misspell. Fuzzy search ensures they still find what they’re looking for:
SELECT * FROM products
WHERE MATCH('sansung glaxy')
OPTION fuzzy=1, distance=2;
This query would successfully match products containing “Samsung Galaxy” despite the typos.
Content Management
For content-heavy sites, fuzzy search helps users discover relevant articles even when they misremember terms or titles:
SELECT * FROM articles
WHERE MATCH('artifical inteligence')
OPTION fuzzy=1;
This would match articles about “artificial intelligence” despite the spelling errors.
International Websites
For sites serving multilingual audiences, keyboard layout awareness is particularly valuable:
SELECT * FROM content
WHERE MATCH('ghdbtn')
OPTION fuzzy=1, layouts='us,ru';
This would match content with “привет” (Russian for “hello”) when a user accidentally types with the wrong keyboard layout.
Conclusion
Fuzzy search is no longer optional - it’s essential for modern search implementations. Manticore Search provides sophisticated yet accessible fuzzy search capabilities that can significantly enhance user experience while accommodating natural variations in human-generated queries.
By leveraging Manticore’s Levenshtein distance algorithm and unique keyboard layout awareness, you can create search experiences that feel almost magical to users. They’ll find what they’re looking for even when they don’t get the query exactly right.
Whether you’re building an e-commerce platform, content management system, or any application with search functionality, implementing fuzzy search with Manticore can lead to higher user satisfaction, better engagement, and ultimately, improved conversion rates.