Fuzzy clause of a term query uses the raw text, so typos in capitalized or stemmed words never match

Fess version: 15.9.0

Problem

TermQueryCommand#buildDefaultTermQuery adds fuzzyQuery(title, text) and fuzzyQuery(content, text) with the text exactly as typed. A fuzzy query is term-level and not analyzed, but title and content are indexed with standard_analyzer (asciifolding, lowercase, stemmer_en_filter, …). So the edit distance is measured against the analyzed terms:

  • an uppercase letter costs one edit by itself;
  • a word the English stemmer shortens is stored stemmed, so a typo in it is several edits away.

Examples (index contains “Fabian” and “Onboarding”)

query hits why
fbian 2,524 1 edit to fabian
Fbian 0 F → f + missing a = 2 edits, AUTO allows 1 for 5 characters
onbording 0 indexed term is onboard (stemmed), 4 edits away

Capitalized nouns (German) and inflected words (English -ing, -s, -ed) are common, so the fuzzy clause rarely helps.

Proposed fix

Use an analyzed query with fuzziness instead of a raw fuzzyQuery, e.g. matchQuery(field, text).fuzziness(...).prefixLength(...).maxExpansions(...).fuzzyTranspositions(...). The text then goes through the field’s search analyzer first (Onbording → onbord, 1 edit to onboard; Fbian → fbian, 1 edit to fabian).

Tested on the same index with fuzziness: AUTO, max_expansions: 10 on content:

query fuzzy (current) match + fuzziness
Onbording 0 1,556
Fbian 0 2,524

Thanks for the detailed report — you were right. The fuzzy clause compared the raw text against the analyzed index terms, so capitalized or stemmed typos (e.g. Fbian, Onbording) never matched.

This is fixed in Fess 15.10: the clause is now a match query with fuzziness, so the text goes through the analyzer first.