Skip to main content
Fuzzy search matches terms that are similar to, but not an exact match for, a query term. Unlike semantic search, which matches terms by meaning using vector embeddings, fuzzy search matches by spelling, using character-level edit distance to catch typos and minor variants. While Lucidworks Search has no single fuzzy search feature, you can combine Solr’s native fuzzy matching with query pipeline stages, choosing an approach based on your search architecture and how much precision you’re willing to trade for recall.

Choose an approach

Depending on your use case and existing pipeline stages, there are several possible approaches to fuzzy search:

Spell Check stage

The simplest option. Surfaces “Did you mean?” suggestions when a query returns few results. No custom code required.

JavaScript Query stage

Rewrites query terms with Solr’s fuzzy tilde operator before they reach Solr. Use this to make fuzzy matching automatic for every query.

Additional Query Parameters stage

Applies the {!fuzzy} query parser to a specific field, such as a product title, without affecting other fields.

Neural Hybrid Search

If you’re already running NHS, its semantic vector matching handles most misspelling-like cases without any fuzzy configuration.

Spell check stage

Add a Spell Check query stage after your Solr Query stage (or Neural Hybrid Query stage) in the query pipeline. It triggers Solr’s spell checker when result counts fall below a threshold you configure, and returns spelling suggestions without any custom code.

JavaScript query stage

Solr supports fuzzy matching natively with the tilde operator: roam~1 matches terms within an edit distance of 1, such as foam or roams. Edit distance ranges from 0–2, but start with 1. An edit distance of 2 expands matching aggressively and can degrade both precision and query performance. Add a JavaScript Query stage before your Solr Query stage to rewrite the q parameter:
Never apply this to an NHS pipeline. NHS requires q to be a raw user query string, not a Solr query parser string. See Neural Hybrid Search.
Skip terms shorter than 4 characters, terms that already contain an operator (:, +, -), quoted phrases, and terms that are already fuzzy. Don’t apply tilde fuzzy to wildcard queries (*); the two syntaxes conflict.
For general background on writing and testing pipeline scripts, see Custom JavaScript Stages for Query Pipelines.

Field-specific fuzzy matching

To apply fuzzy matching to one field only, such as title_t, use the {!fuzzy} query parser with the Additional Query Parameters stage:
integer
Maximum edit distance, from 0–2. Start with 1.
integer
Number of leading characters that must match exactly. Setting this to 2 or higher significantly reduces the number of terms Solr must evaluate and improves performance.
integer
Caps how many term variants Solr evaluates per fuzzy term. Lower this value if you see latency spikes.
boolean
When true, uses Damerau-Levenshtein distance (counts transpositions, such as swapped adjacent letters, as a single edit). When false, uses classic Levenshtein distance.
To rank exact matches first while still surfacing fuzzy matches, keep q exact and add the fuzzy expression as a boost query instead: bq=title_t:searchterm~1. Don’t inject fuzzy tilde syntax or {!fuzzy} local params into the q parameter in a Neural Hybrid Search pipeline. NHS requires q to be a raw user query string; injecting Solr query parser syntax breaks vectorization. See Neural Hybrid Search. In an NHS environment:
  • Rely on NHS’s semantic vector matching, which already handles many misspelling-like cases through embedding proximity.
  • Apply fuzzy matching at the Solr request handler level in solrconfig.xml, outside the NHS query path, if lexical fuzzy matching is still needed.
  • Build a separate lexical-and-fuzzy fallback pipeline that runs only on zero-result queries.
Lucidworks Search’s Misspelling detection feature is deprecated as of Lucidworks Search 5.9.15. Lucidworks recommends Neural Hybrid Search as the replacement for spelling tolerance.