Add fuzzy search fallback (exact first, fuzzy on zero hits) - #477
Open
detournemint wants to merge 5 commits into
Open
Add fuzzy search fallback (exact first, fuzzy on zero hits)#477detournemint wants to merge 5 commits into
detournemint wants to merge 5 commits into
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
When a search returns zero hits, retry once with Levenshtein tolerance so typos, extra words, and near-misses still find cards. Extracts searchOramaIndex into its own module so the search logic is testable outside the worker. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
When a search matches nothing, retry with escalating forgiveness: first with typo tolerance (fuzziness AUTO, all words required), then also tolerating extra words (minimum_should_match 75%). Applies to both the editor search and explore search endpoints. Filters always apply to fallback queries, and no index mapping changes are needed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Reformat with prettier 2.7.1 to match the repo's pinned pre-commit hook - Hoist the client-side fallback decision from per-index to aggregate level so an exact hit in one index suppresses fuzzy matches from others (new searchOramaIndices API, with multi-index tests) - Make the explore view's fallback best-effort like the editor path - Use minimum_should_match 2<75% so one- and two-word queries still require every word during the extra-words fallback - Broaden fallback retry catch to TransportError - Type the explore search closure and document fallback_level Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
detournemint
force-pushed
the
fuzzy-search-fallback
branch
from
August 1, 2026 03:54
7d566eb to
8a6be09
Compare
Author
detournemint
force-pushed
the
fuzzy-search-fallback
branch
from
August 1, 2026 04:49
807be79 to
92bd9f6
Compare
- Reset factory sequences before every test so snapshots no longer depend on which tests run or in what order. Previously, adding any test shifted sequence-generated values (e.g. artist names) in every later test's snapshot, breaking unrelated tests. Regenerates the six affected snapshots. - Skip Moxfield URL tests when MOXFIELD_SECRET is not configured and update_database tests when client_secrets.json is absent or invalid, so fork PRs (which receive no repo secrets) and credential-less local runs pass instead of erroring. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
detournemint
force-pushed
the
fuzzy-search-fallback
branch
from
August 1, 2026 05:14
92bd9f6 to
2bad262
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Currently a search that doesn't exactly match a card name returns nothing — precise mode requires the whole string to match, and even Fuzzy (Forgiving) mode requires every word to match exactly, so typos ("brainstrom") and extra words ("the lightning bolt") yield zero results.
This PR adds a retry-on-miss fallback on both search stacks:
tolerance: 2. The retry decision is made at the aggregate level across indexes, so an exact hit in one index suppresses fuzzy matches from others.fuzziness: AUTOwith all words required, thenminimum_should_match: "2<75%"to also tolerate extra words. Applies to both the editor search and explore search endpoints.Behavior is unchanged whenever the primary search finds at least one result (no pre-existing test snapshots changed). All filters (source, DPI, tags, size) still apply to fallback queries. Fallback retries are best-effort: on ES transport errors the original empty result is returned rather than a new error path.
Implementation notes
searchOramaIndexis extracted from the worker into a pureoramaSearch.tsmodule so the search logic is unit-testable outside the workerTesting
Related: #478 (Explore artist filtering) touches some of the same search plumbing — whichever lands second will need a trivial rebase.
🤖 Generated with Claude Code