feat(subsonic): allow search with MBID (#579)
* feat(search): use search2/3 query to additionally search track MBID * feat(search): use strict equality for MBID search don't compare substrings for now to reduce unwanted results based on MBIDs might also make search more efficient * feat(db): add migration to create index on MBID for MBID search * tweak(search): remove unnecessary trim on query
This commit is contained in:
No files matched your search
@@ -77,6 +77,7 @@ func (db *DB) Migrate(ctx MigrationContext) error {
|
|||||||
construct(ctx, "202501152036", migrateAlbumAddIndexOnParentID),
|
construct(ctx, "202501152036", migrateAlbumAddIndexOnParentID),
|
||||||
construct(ctx, "202502012036", migratePodcastEpisode),
|
construct(ctx, "202502012036", migratePodcastEpisode),
|
||||||
construct(ctx, "202504132036", migratePodcast),
|
construct(ctx, "202504132036", migratePodcast),
|
||||||
|
construct(ctx, "202505211202", migrateTrackAddIndexOnBrainzID),
|
||||||
}
|
}
|
||||||
|
|
||||||
return gormigrate.
|
return gormigrate.
|
||||||
@@ -840,3 +841,9 @@ func migratePodcastEpisode(tx *gorm.DB, _ MigrationContext) error {
|
|||||||
PodcastEpisode{},
|
PodcastEpisode{},
|
||||||
).Error
|
).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func migrateTrackAddIndexOnBrainzID(tx *gorm.DB, _ MigrationContext) error {
|
||||||
|
return tx.Exec(`
|
||||||
|
CREATE INDEX idx_tracks_brainz_id ON "tracks" (tag_brainz_id);
|
||||||
|
`).Error
|
||||||
|
}
|
||||||
@@ -263,7 +263,7 @@ func (c *Controller) ServeSearchTwo(r *http.Request) *spec.Response {
|
|||||||
var tracks []*db.Track
|
var tracks []*db.Track
|
||||||
q = c.dbc.Preload("Album")
|
q = c.dbc.Preload("Album")
|
||||||
for _, s := range queries {
|
for _, s := range queries {
|
||||||
q = q.Where(`filename LIKE ? OR filename LIKE ?`, s, s)
|
q = q.Where(`filename LIKE ? OR filename LIKE ? OR tag_brainz_id = ?`, s, s, query)
|
||||||
}
|
}
|
||||||
q = q.
|
q = q.
|
||||||
Preload("Artists").
|
Preload("Artists").
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
|
|||||||
Preload("TrackStar", "user_id=?", user.ID).
|
Preload("TrackStar", "user_id=?", user.ID).
|
||||||
Preload("TrackRating", "user_id=?", user.ID)
|
Preload("TrackRating", "user_id=?", user.ID)
|
||||||
for _, s := range queries {
|
for _, s := range queries {
|
||||||
q = q.Where(`tracks.tag_title LIKE ? OR tracks.tag_title_u_dec LIKE ?`, s, s)
|
q = q.Where(`tracks.tag_title LIKE ? OR tracks.tag_title_u_dec LIKE ? OR tracks.tag_brainz_id = ?`, s, s, query)
|
||||||
}
|
}
|
||||||
q = q.Offset(params.GetOrInt("songOffset", 0)).
|
q = q.Offset(params.GetOrInt("songOffset", 0)).
|
||||||
Limit(params.GetOrInt("songCount", 20))
|
Limit(params.GetOrInt("songCount", 20))
|
||||||
|
|||||||
Reference in New Issue
Block a user