-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: MBID search functionality for albums, artists and songs #4286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Updated the search methods in the mediaFileRepository, albumRepository, and artistRepository to support searching by MBID in addition to the existing query methods. This change improves the efficiency of media file, album, and artist searches, allowing for faster retrieval of records based on MBID. Signed-off-by: Deluan <deluan@navidrome.org>
Updated the search functionality to support searching by MBID for both albums and artists. The fullTextFilter function was modified to accept additional MBID fields, allowing for more comprehensive searches. New tests were added to ensure that the search functionality correctly handles MBID queries, including cases for missing entries and the includeMissing parameter. This enhancement improves the overall search capabilities of the application, making it easier for users to find specific media items by their unique identifiers. Signed-off-by: Deluan <deluan@navidrome.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @deluan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces a major enhancement to the search capabilities by integrating MusicBrainz ID (MBID) support across albums, artists, and media files. The core idea is to leverage standardized metadata identifiers for more precise and performant searches, automatically prioritizing MBID lookups when a valid UUID is provided as a query. This change includes necessary database schema updates, modifications to the underlying search logic, and comprehensive testing to ensure reliability and backward compatibility.
Highlights
- Enhanced Search Functionality: The Subsonic API search has been significantly enhanced to support searching by MusicBrainz ID (MBID) for albums, artists, and media files. This provides more accurate and efficient results for users with MusicBrainz-tagged libraries.
- MBID Search Prioritization: When a search query is detected as a valid UUID (MBID format), the system now prioritizes MBID-based searches over traditional full-text searches, ensuring direct and precise matches.
- Database Indexing for Performance: New database indexes have been added to
mbz_artist_id
,mbz_album_id
, andmbz_release_track_id
fields in theartist
,album
, andmedia_file
tables, respectively, to optimize the performance of MBID lookups. - Refactored Search Logic: The
fullTextFilter
function has been updated to accept additional MBID fields, and a newsearchByMBID
method along with anmbidExpr
helper function have been introduced insql_search.go
to encapsulate the MBID-specific search logic. - Comprehensive Test Coverage: New unit tests have been added for the
fullTextFilter
with MBID functionality, covering UUID validation, MBID precedence, and edge cases, ensuring the robustness of the new search capabilities.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the Subsonic API search functionality by adding support for MusicBrainz ID (MBID)–based searches across albums, artists, and media files. Key changes include:
- Introducing new MBID search functions (searchByMBID and mbidExpr) to prioritize valid UUID queries.
- Updating repository Search methods to leverage MBID filtering and adding corresponding database indexes.
- Expanding test coverage to verify MBID search behavior and consistency with full-text searches.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
persistence/sql_search.go | Added MBID search functions (searchByMBID and mbidExpr) for MBID-based filtering |
persistence/sql_restful.go | Updated fullTextFilter to accept MBID fields and build a combined condition |
persistence/sql_restful_test.go | Extended tests to cover MBID and full-text filtering behavior |
persistence/mediafile_repository.go | Modified Search to use MBID filtering when a valid UUID is detected |
persistence/artist_repository.go | Modified Search to use MBID filtering when a valid UUID is detected |
persistence/album_repository.go | Modified Search to use MBID filtering when a valid UUID is detected |
db/migrations/20250701010107_add_mbid_indexes.sql | Added indexes for MBID fields to optimize search performance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces MBID search functionality, enhancing search accuracy and efficiency. The implementation includes database indexes and tests. However, the searchByMBID
function is missing pagination, and the fullTextFilter
function could be more efficient by prioritizing MBID searches.
Updated the MBID handling in the SQL search logic to convert the input to lowercase before executing the query. This change ensures that searches are case-insensitive, improving the accuracy and reliability of the search results when querying by MBID. Signed-off-by: Deluan <deluan@navidrome.org>
Description
This PR enhances the Subsonic API search functionality to support searching by MusicBrainz ID (MBID) for albums, artists, and media files. This improvement provides more accurate and efficient searches when users have MBID information available.
The implementation prioritizes MBID searches over full-text searches when valid UUIDs are detected, providing better search accuracy for users with MusicBrainz-tagged music libraries.
Type of Change
Checklist
Please review and check all that apply:
How to Test
make test PKG=./persistence/...
Technical Details
Key Changes:
fullTextFilter
function to accept additional MBID fields for enhanced search capabilitiesDatabase Changes:
mbz_album_id
,mbz_artist_id
) for albums and artists20250701010107_add_mbid_indexes.sql
Code Changes:
persistence/sql_restful.go
: Enhanced fullTextFilter to handle MBID searchespersistence/album_repository.go
: Added MBID field to search configurationpersistence/artist_repository.go
: Added MBID field to search configurationpersistence/mediafile_repository.go
: Added MBID field to search configurationpersistence/sql_search.go
: Enhanced search logic for MBID supportTest Coverage:
persistence/sql_restful_test.go
,persistence/artist_repository_test.go
, andpersistence/mediafile_repository_test.go
Additional Notes
This enhancement maintains backward compatibility while improving search accuracy for users with MusicBrainz-tagged music libraries. The implementation follows the existing patterns in the codebase and includes proper error handling and comprehensive test coverage.
The feature automatically detects when a search query is a valid UUID (MBID format) and prioritizes MBID-based searches in those cases, falling back to traditional full-text search for non-UUID queries.