Skip to content

feat: fuzzy search with relevance ranking and highlight#3

Open
hermes-alby wants to merge 1 commit intogetAlby:mainfrom
hermes-alby:feat/fuzzy-search
Open

feat: fuzzy search with relevance ranking and highlight#3
hermes-alby wants to merge 1 commit intogetAlby:mainfrom
hermes-alby:feat/fuzzy-search

Conversation

@hermes-alby
Copy link
Copy Markdown
Contributor

Summary

Replace the simple substring-only search with a proper fuzzy search that scores and ranks results by relevance.

Before

  • Only matched exact substring in title + description
  • No scoring or ranking — results appeared in original order
  • Typing "nostr wallet" would return nothing unless that exact phrase existed

After

  • Multi-level scoring: exact match > startsWith > word boundary > substring > fuzzy subsequence
  • Multi-word queries — each word is matched independently, so "nostr wallet" finds apps mentioning both
  • Relevance ranking — title matches are scored 100x higher than description matches, so results appear in order of relevance
  • Match highlighting — matching text is highlighted with a yellow background in search results
  • Zero dependencies added (~150 lines of pure TypeScript)

How scoring works

  • 100 = exact match
  • 90 = starts with query
  • 80 = word boundary match
  • 70 = mid-string substring match
  • 30-75 = multi-word fuzzy match
  • 40-59 = single-word fuzzy subsequence

- Replace substring-only search with fuzzy matching algorithm
- Score results: exact match > startsWith > word boundary > substring > fuzzy
- Support multi-word queries (all words must match for each result)
- Results sorted by relevance score (title matches ranked much higher than description)
- Highlight matching text in search results with yellow background
- All existing tests pass
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.

1 participant