Skip to content

fix: search relevance and artist metadata matching#4

Open
reifocS wants to merge 2 commits into
mainfrom
fix/search-relevance-and-artist-matching
Open

fix: search relevance and artist metadata matching#4
reifocS wants to merge 2 commits into
mainfrom
fix/search-relevance-and-artist-matching

Conversation

@reifocS
Copy link
Copy Markdown
Contributor

@reifocS reifocS commented Apr 3, 2026

Summary

MusicBrainz artist matching

  • /api/metadata/artist/Mestís returned data for "Mest" (punk rock) instead of "Mestís" (progressive)
  • MusicBrainz search used limit=1 and blindly took the first fuzzy match
  • Now fetches 5 results and picks the best normalized match via _pick_best_mb_artist()
  • get_artist_info() only overwrites the query name when the MB result is a genuine match (accent/casing difference)

Search result ranking

  • Searching "mestis" returned garbage like "Steel Meets Steel", "Chopis Centis" at the top
  • fuzzy_match() was too loose: substring check matched partial words, Levenshtein distance=2 matched "mestis" to "mystic"
  • Scoring had no artist-name awareness — a tab by "Mestís" scored the same as random fuzzy matches
  • Fix: tighter substring/Levenshtein thresholds + artist name match gives +300/+200 score boost

Test plan

  • Search "mestis" — should return 0 local results (no garbage), live results from Songsterr show Mestís tabs
  • Search "metallica" — 379 results, top scored correctly
  • Search "chopin" — Chopin results at top
  • /api/metadata/artist/Mestís — returns Mestís data, not Mest
  • /api/metadata/artist/Mest — still returns Mest data correctly

reifocS added 2 commits April 3, 2026 19:23
The artist metadata endpoint /api/metadata/artist/Mestís returned data
for "Mest" (punk rock) instead of "Mestís" (Javier Reyes, progressive).

Root cause: MusicBrainz search used limit=1 and blindly took the first
fuzzy match. "Mest" ranked higher than "Mestís" in MB's fuzzy scoring.

Fix:
- Fetch 5 results from MusicBrainz instead of 1
- Pick the best match using _pick_best_mb_artist(): exact normalized
  match first, then starts-with, then fall back to MB score
- Only overwrite the query name with MB name when it's a normalized
  match (accent/casing differences), not a completely different artist
- Guard the TheAudioDB canonical-name fallback with the same check
Searching "mestis" returned garbage like "Steel Meets Steel", "Chopis
Centis", "Les Meutes" because:

1. fuzzy_match() used loose substring check (qw in tw) and Levenshtein
   distance=2 for 6+ char words. "mestis" matched "mystic" (dist=2),
   "meets" (dist=2), etc. Now:
   - Substring only matches if query covers 70%+ of the target word
   - Levenshtein threshold=1 for words under 8 chars
   - Length difference capped at 1 char

2. Scoring had no artist-name awareness. A tab by artist "Mestís" scored
   the same as random fuzzy matches. Now:
   - Exact artist match: +300
   - Artist word overlap with query: +200
   - Uses accent-stripped comparison for both
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tablatures-api Ready Ready Preview, Comment Apr 3, 2026 5:24pm

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