Skip to main content

Module fuzzy

Module fuzzy 

Source
Expand description

Fuzzy string matching via Levenshtein edit distance.

Used for typo-tolerant full-text search. When an exact term match isn’t found in the inverted index, fuzzy matching finds terms within a configurable edit distance.

Distance thresholds are adaptive based on token length:

  • 1-3 chars: exact only (no fuzzy — too many false positives)
  • 4-6 chars: max distance 1
  • 7+ chars: max distance 2

Functions§

fuzzy_discount
Score discount for fuzzy matches based on edit distance.
fuzzy_match
Find terms in the index that fuzzy-match the query term.
levenshtein
Compute Levenshtein edit distance between two strings.
max_distance_for_length
Maximum allowed edit distance for a given token length.