Elasticsearch dual-write sync, bulk reindex, and reindex endpoint#232
Draft
jakebromberg wants to merge 2 commits intofeature/elasticsearch-searchfrom
Draft
Elasticsearch dual-write sync, bulk reindex, and reindex endpoint#232jakebromberg wants to merge 2 commits intofeature/elasticsearch-searchfrom
jakebromberg wants to merge 2 commits intofeature/elasticsearch-searchfrom
Conversation
…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.
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
elasticsearch.sync.tsstubs:indexLibraryDocumentById,removeLibraryDocument,bulkIndexLibrary(batches of 500, returns{ indexed, errors }counts)library.service.ts:insertAlbum,addToRotation,killRotationInDBfire-and-forget sync to ES after DB writesPOST /library/reindexendpoint (requirescatalog: ['write']) for full bulk reindexCloses #231
Test plan
npm run test:unit— 291 tests pass (23 suites), including 24 new testsnpm run typecheck— cleannpm run lint— 0 errorsELASTICSEARCH_URL=http://localhost:9200, callPOST /library/reindex, verify ES has documentsPOST /libraryto add album, verify it appears in ES via searchELASTICSEARCH_URLset, verify all writes succeed with no ES errors