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.
This commit is contained in:
2026-03-30 01:41:25 -04:00
parent b613e03398
commit 0a72455f37
3 changed files with 11 additions and 1 deletions
+9 -1
View File
@@ -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
})
}
+1
View File
@@ -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
+1
View File
@@ -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