Add FTS-backed search (songs/albums/artists) and DB migration#842
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5cf8f0ba18
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| db.execSQL(""" | ||
| CREATE VIRTUAL TABLE IF NOT EXISTS songs_fts | ||
| USING fts4( | ||
| title, | ||
| artist_name, |
There was a problem hiding this comment.
Add FTS sync triggers for migrated databases
The migration creates external-content FTS tables (content='songs', etc.) but does not create any triggers or other update path to keep the FTS index in sync after the one-time rebuild. For users upgrading from v11, any subsequent inserts/updates/deletes to songs/albums/artists will not update the FTS tables, so search results will silently miss new or modified items. To avoid stale search results, add the standard FTS4 content-table triggers in this migration (or switch to a Room migration that generates them).
Useful? React with 👍 / 👎.
Motivation
LIKE '%query%'full-table scans with an indexed full-text search to reduce CPU and latency for searches, following the optimization plan inOPTIM.md.Description
SongFtsEntity,AlbumFtsEntity,ArtistFtsEntity) inSearchFtsEntities.ktto model FTS tables for songs, albums and artists.12and addMIGRATION_11_12inPixelPlayDatabase.ktwhich createssongs_fts,albums_fts, andartists_ftsvirtual tables and triggers a rebuild.LIKEqueries with FTSMATCHqueries inMusicDao.ktand join the base tables with the FTS virtual tables for search results.MusicRepositoryImpl.ktto build safe prefix FTS queries viabuildFtsQuery(rawQuery)and pass the generated FTS query to the DAO, and register the new migration inAppModule.kt.Testing
Codex Task