fix(docs): disable fuzzy matching in docs search (exact word or prefix only) (#65103)

The docs search theme (@easyops-cn/docusaurus-search-local) defaults
fuzzyMatchingDistance to 1, so every term also matched words one edit
away. Two user-visible failures on the 14.4 MB production index:

- Wrong results: 'keet' returned 'Microsoft Teams Meetings',
  'google_meet', 'Keep the Model Loaded' etc. — 'meet' and 'keep' are
  both one edit from 'keet', and the stemmer indexes 'meetings' as
  'meet'.
- Search appearing to die: fuzzy matching multiplies the generated
  lunr queries (distance matrix x maybe-typing variants x
  leave-one-out terms — up to 210 queries per keystroke on multi-word
  input), and fuzzy REQUIRED terms are the expensive scan kind. A
  typo'd 3-word query stalled the single-threaded search Web Worker
  for 25+ seconds; every later keystroke's search queued behind it,
  so the bar stopped returning results.

Setting fuzzyMatchingDistance: 0 keeps exact-word-or-prefix semantics
(keet -> keet*), which is the behavior users asked for. Validated by
running the plugin's shipped smartQueries/tokenize code against the
downloaded production search-index.json: legitimate queries (cron,
telegram, prefix 'memor') return identical results; worst-case typo
queries drop from 210 queries / 365-532ms per keystroke to 50-105 /
53-188ms; false 'keet' matches gone.
This commit is contained in:
Teknium 2026-07-15 09:57:46 -07:00 committed by GitHub
parent fcdc10a0f3
commit 2106f63723
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -62,6 +62,14 @@ const config: Config = {
/^user-guide\/skills\/bundled\//,
/^user-guide\/skills\/optional\//,
],
// Exact-or-prefix matching only (default is edit distance 1).
// With fuzzy distance 1, "keet" matched "meetings"/"keep" (one
// edit away after stemming), and multi-word typo queries against
// our ~14 MB index could stall the single-threaded search worker
// for 25s+, backing up every subsequent keystroke's search until
// the bar appeared dead. Distance 0 keeps "word or its extension"
// semantics (keet -> keet*) and removes the pathological scans.
fuzzyMatchingDistance: 0,
}),
],
],