Improve search relevance and artist transliteration
This commit is contained in:
1 parent
db4548b115
commit
82f3eed9a0
10 files changed
+212
-12
No files matched your search
@@ -43,6 +43,7 @@ type limits struct{ artists, albums, tracks, offset int }
|
||||
|
||||
type found struct {
|
||||
artists, albums, tracks []string
|
||||
exactArtists []string
|
||||
totals [3]int
|
||||
}
|
||||
|
||||
@@ -50,7 +51,11 @@ func (h *Handler) query(ctx context.Context, q string, l limits) (found, error)
|
||||
var queries []MultiQuery
|
||||
add := func(index string, n int) {
|
||||
if n > 0 {
|
||||
queries = append(queries, MultiQuery{IndexUID: index, Q: q, Limit: n, Offset: l.offset, AttributesToRetrieve: []string{"id"}})
|
||||
attrs := []string{"id"}
|
||||
if index == IndexArtists {
|
||||
attrs = append(attrs, "name", "name_translit")
|
||||
}
|
||||
queries = append(queries, MultiQuery{IndexUID: index, Q: q, Limit: n, Offset: l.offset, MatchingStrategy: "all", AttributesToRetrieve: attrs})
|
||||
}
|
||||
}
|
||||
add(IndexArtists, l.artists)
|
||||
@@ -71,6 +76,7 @@ func (h *Handler) query(ctx context.Context, q string, l limits) (found, error)
|
||||
switch k {
|
||||
case 0:
|
||||
f.artists = res[i].IDs
|
||||
f.exactArtists = res[i].ExactIDs
|
||||
case 1:
|
||||
f.albums = res[i].IDs
|
||||
case 2:
|
||||
@@ -181,7 +187,7 @@ func (h *Handler) personal(ctx context.Context, f found, want limits) found {
|
||||
h.log.WarnContext(ctx, "suggest personalization failed", "err", err)
|
||||
}
|
||||
}
|
||||
f.artists = personalize(f.artists, aff, want.artists)
|
||||
f.artists = personalizeArtists(f.artists, f.exactArtists, aff, want.artists)
|
||||
f.albums = personalize(f.albums, aff, want.albums)
|
||||
f.tracks = personalize(f.tracks, aff, want.tracks)
|
||||
return f
|
||||
|
||||
Reference in new issue
Block a user