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:
Field-specific fuzzy matching
To apply fuzzy matching to one field only, such astitle_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.q exact and add the fuzzy expression as a boost query instead: bq=title_t:searchterm~1.
Neural Hybrid Search
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.
Fusion’s Misspelling Detection feature is deprecated as of Fusion 5.9.15. Lucidworks recommends Neural Hybrid Search as the replacement for spelling tolerance.