Typo Tolerance
Typo tolerance enables fuzzy matching so users find results even when they misspell search terms. Skirre uses edit distance (Levenshtein distance) to match query terms against indexed content.
Overview
When typo tolerance is enabled, Skirre considers terms within a small edit distance of the query term as matches. For example, searching for "nikee" still finds results containing "Nike" because the edit distance is 1.
The number of allowed typos depends on the length of the query term. Short words require exact matches while longer words tolerate more typos. This prevents false positives on short terms where a single character change often produces a completely different word.
How It Works
Skirre applies up to 2 typos per query term based on word length:
| Parameter | Type | Description |
|---|---|---|
| 0 typos optional | rule | Words shorter than min_word_length_1_typo. Exact match required. |
| 1 typo optional | rule | Words at least min_word_length_1_typo characters long but shorter than min_word_length_2_typos. |
| 2 typos optional | rule | Words at least min_word_length_2_typos characters long. |
With default settings (1 typo at 4 chars, 2 typos at 8 chars):
"tv"(2 chars): exact match only, no typos allowed"nike"(4 chars): 1 typo allowed, so "nikee", "nke", "niek" all match"sneakers"(8 chars): 2 typos allowed, so "snaekers", "sneeker" match
Configuration
Configure typo tolerance per-index through the Settings API:
await idx.updateSettings({ typo_tolerance: { enabled: true, min_word_length_1_typo: 4, min_word_length_2_typos: 8, }, });
| Parameter | Type | Description |
|---|---|---|
| enabled optional | boolean | Enable or disable typo tolerance. Default: true |
| min_word_length_1_typo optional | number | Minimum word length to tolerate 1 typo. Default: 4 |
| min_word_length_2_typos optional | number | Minimum word length to tolerate 2 typos. Default: 8 |
Tuning
More permissive (better recall)
Lower the thresholds to tolerate typos on shorter words:
{
"typo_tolerance": {
"enabled": true,
"min_word_length_1_typo": 3,
"min_word_length_2_typos": 5
}
}This allows 1 typo on 3-letter words (e.g. "nke" → "Nike") and 2 typos on 5+ letter words. Better for casual search experiences where users type quickly.
More strict (better precision)
Raise the thresholds to require longer words before typos are tolerated:
{
"typo_tolerance": {
"enabled": true,
"min_word_length_1_typo": 5,
"min_word_length_2_typos": 10
}
}Better for technical search where short terms have precise meanings (e.g. model numbers, codes).
Examples
Default settings (4/8)
| Parameter | Type | Description |
|---|---|---|
| "tv" → "tv" optional | exact | 2 chars, below threshold. Exact match only. |
| "niike" → "nike" optional | 1 typo | 5 chars, above 4-char threshold. 1 typo tolerated. |
| "snaekers" → "sneakers" optional | 2 typos | 8 chars, above 8-char threshold. 2 typos tolerated. |
Permissive settings (3/5)
| Parameter | Type | Description |
|---|---|---|
| "nke" → "nike" optional | 1 typo | 3 chars, above 3-char threshold. 1 typo tolerated. |
| "sheos" → "shoes" optional | 2 typos | 5 chars, above 5-char threshold. 2 typos tolerated. |