Elasticsearch dual-write sync, bulk reindex, and reindex endpoint#232
Open
jakebromberg wants to merge 4 commits intofeature/elasticsearch-searchfrom
Open
Elasticsearch dual-write sync, bulk reindex, and reindex endpoint#232jakebromberg wants to merge 4 commits intofeature/elasticsearch-searchfrom
jakebromberg wants to merge 4 commits intofeature/elasticsearch-searchfrom
Conversation
added 4 commits
March 21, 2026 11:25
…dex endpoint Wire Elasticsearch sync into the library service layer so album inserts, rotation adds, and rotation kills are dual-written to ES as fire-and-forget operations. Errors are logged but never propagated, so library operations succeed even when ES is unavailable. Add POST /library/reindex endpoint (requires catalog write permission) that bulk-indexes all library_artist_view rows into ES in batches of 500. Add unit tests for all sync functions and verify dual-write calls from library service functions.
Drizzle ORM references underlying table column names (e.g. artist_genre_code) instead of view column aliases (e.g. code_artist_number) when using db.select().from(view). Switch to raw SQL with db.execute() for library_artist_view queries. Also fix add_date serialization: postgres-js returns timestamp strings (not Date objects) from raw queries, so parse through new Date() to produce valid ISO strings for ES.
The GET /library endpoint accepted album_title as a query parameter, but the OpenAPI spec (CatalogSearchParams) and the dj-site frontend both send album_name. This caused album searches to be silently ignored. Closes #233
After rebasing on main, the LibraryArtistViewEntry type gained a label_id field from the labels table feature. Update the ES index mapping, document serialization, hit deserialization, and test fixtures to include it.
2a94a21 to
b639450
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
insertAlbum,addToRotation, andkillRotationInDBfire-and-forget index updates to ESbulkIndexLibrary()for full reindex in batches of 500, with error counting for observabilityPOST /library/reindexendpoint (requirescatalog: ['write'])removeLibraryDocument()with 404 tolerancelabel_idto ES index mapping, sync serialization, and hit deserialization (from main's labels feature)album_titlequery param toalbum_nameto match API specCloses #252
Test plan
elasticsearch.sync.ts(indexing, removal, bulk, chunking, error handling, null client)library.service.ts(dual-write calls, error isolation)npm run typecheckcleannpm run lint0 errorsPOST /library/reindexwith ES runningPOST /librarythen search — dual-write worksELASTICSEARCH_URL— graceful degradation