Skip to content

fix: replace hand-rolled fuzzy search with @nozbe/microfuzz#15

Merged
stackingsaunter merged 1 commit intogetAlby:mainfrom
hermes-alby:fix/fuzzy-search-microfuzz
Apr 16, 2026
Merged

fix: replace hand-rolled fuzzy search with @nozbe/microfuzz#15
stackingsaunter merged 1 commit intogetAlby:mainfrom
hermes-alby:fix/fuzzy-search-microfuzz

Conversation

@hermes-alby
Copy link
Copy Markdown
Contributor

Problem

Searching for "cashu" returned 13+ irrelevant results (Club Orange, CornyChat, Podcast Index, Podhome, Highlighter, Slice, BTCPay Server, Zeus, Bitcoin Well, Alby PaidMCP…) because the hand-rolled fuzzySubsequence() gave non-zero scores to characters scattered anywhere in the text.

Solution

Replace the hand-rolled fuzzy search with @nozbe/microfuzz — a tiny (zero-dependency) fuzzy search library with a "smart" strategy that filters out poor-quality subsequence matches.

Changes

  • src/lib/discover.ts — Remove fuzzyScore, fuzzySubsequence, scoreAppForQuery, fuzzySearchMatches (~80 lines). Add searchApps() using microfuzz with strategy: "smart" and a WeakMap cache for the searcher instance.
  • src/components/app-card.tsx — Replace hand-rolled bestMatchIndex + single-span highlighting with microfuzz HighlightRanges for precise multi-range highlighting.
  • src/App.tsx — Compute search results map and pass titleRanges/descriptionRanges to AppCard.

Before → After ("cashu" search)

Before After
13+ results (mostly noise) 3 results (all relevant)
Club Orange, CornyChat, Podcast Index… Shopstr, Satsback, Cashu Redeem

Verification

  • tsc --noEmit passes
  • npm run build passes
  • ✅ All 8 unit tests pass
  • ✅ Tested live — search works correctly

The previous fuzzy search implementation was too permissive — searching
for 'cashu' returned 13+ irrelevant results (Club Orange, CornyChat,
Podcast Index, etc.) because the subsequence matching gave non-zero
scores to characters scattered across long descriptions.

Replace the hand-rolled fuzzyScore/fuzzySubsequence with @nozbe/microfuzz,
a tiny zero-dependency library with a 'smart' strategy that filters out
poor-quality matches. Also use microfuzz's built-in highlight ranges
for more precise search result highlighting.

Before: 'cashu' → 13+ results (mostly noise)
After:  'cashu' → 3 results (Shopstr, Satsback, Cashu Redeem)
@hermes-alby hermes-alby force-pushed the fix/fuzzy-search-microfuzz branch from 9ebdc57 to 1ebe4b1 Compare April 10, 2026 13:43
@github-actions
Copy link
Copy Markdown
Contributor

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://getAlby.github.io/bitcoin-apps/pr-preview/pr-15/

Built to branch gh-pages at 2026-04-10 13:44 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@stackingsaunter stackingsaunter merged commit 6d93045 into getAlby:main Apr 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants