From 0a72455f37f79e986122db073bcbe72d538333d7 Mon Sep 17 00:00:00 2001 From: Caleb Allen Date: Mon, 30 Mar 2026 01:41:25 -0400 Subject: [PATCH] fix: sort same-tier artists by blended score, not original MB score Within the same name-match tier, the US Teenagers (MB score 100) ranked above the FR Teenagers (MB score 93) because the tiebreaker used OriginalScore. But the FR band is globally more popular (1.3M vs 23K listens) and has the higher blended score (82 vs 72). Changed the within-tier tiebreaker to use the blended Score, which already incorporates both text relevance and popularity. This ranks the more well-known artist first among same-named exact matches. Added OriginalScore field to MBArtist (json:"-" so it doesn't affect the frontend) to preserve the pre-reranking MB score for potential future use. --- backend/explore/explore.go | 10 +++++++++- backend/explore/musicbrainz.go | 1 + backend/explore/types.go | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/backend/explore/explore.go b/backend/explore/explore.go index cdc0897..8d03875 100644 --- a/backend/explore/explore.go +++ b/backend/explore/explore.go @@ -1090,6 +1090,9 @@ func boostNameMatches(query string, result *MBSearchResult) { } // Boost artists whose name contains the full query. + // Within the same tier, sort by original MB relevance score + // (not the library-boosted blended score) so the most globally + // relevant exact match ranks first. if len(result.Artists) > 1 { sort.SliceStable(result.Artists, func(i, j int) bool { iMatch := nameMatchTier(q, strings.ToLower(result.Artists[i].Name)) @@ -1099,7 +1102,12 @@ func boostNameMatches(query string, result *MBSearchResult) { return iMatch < jMatch // lower tier = better match } - return false // preserve existing order within same tier + // Within same tier, prefer higher blended score. + if result.Artists[i].Score != result.Artists[j].Score { + return result.Artists[i].Score > result.Artists[j].Score + } + + return false // preserve existing order as last resort }) } diff --git a/backend/explore/musicbrainz.go b/backend/explore/musicbrainz.go index 01c20a3..e294ef1 100644 --- a/backend/explore/musicbrainz.go +++ b/backend/explore/musicbrainz.go @@ -378,6 +378,7 @@ func convertArtist(a musicbrainzws2.Artist) MBArtist { Country: string(a.CountryCode), Disambiguation: a.Disambiguation, Score: a.Score, + OriginalScore: a.Score, } // Extract the primary English alias when the canonical name diff --git a/backend/explore/types.go b/backend/explore/types.go index b0a1252..fa44676 100644 --- a/backend/explore/types.go +++ b/backend/explore/types.go @@ -25,6 +25,7 @@ type MBArtist struct { Country string `json:"country"` Disambiguation string `json:"disambiguation"` Score int `json:"score"` + OriginalScore int `json:"-"` // MB search relevance, preserved across reranking } // MBReleaseGroup is a Wails-friendly projection of a MusicBrainz