Add Elasticsearch as optional search backend#230
Draft
jakebromberg wants to merge 1 commit intomainfrom
Draft
Conversation
…adation to pg_trgm Adds a search facade that routes library catalog queries to Elasticsearch when ELASTICSEARCH_URL is set, falling back to PostgreSQL pg_trgm on any ES error or when the env var is unset. This enables Lucene-powered fuzzy matching, stemming, and relevance ranking while preserving the existing pg_trgm behavior as the default. New files: ES client singleton, index mapping/lifecycle, ES search implementations (searchLibraryES, findSimilarArtistES, searchAlbumsByTitleES, searchByArtistES), sync stubs (PR 2), and the search facade. Renames pg_trgm functions with pgTrgm prefix and re-exports facade versions under the original names so no callers need to change imports. Also adds: Docker Compose ES services (dev + ci profiles), expanded /healthcheck with ES status, unit tests for client, search, and facade, updated CLAUDE.md and .env.example.
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
apps/backend/services/search/) that routes to ES whenELASTICSEARCH_URLis set, falls back to pg_trgm on any errorpgTrgmprefix and re-exports facade versions under the original names (no callers need to change)/healthcheckto report ES status (connected,unavailable, ordisabled)Closes #229
Test plan
npm run test:unit-- all 266 tests pass (21 suites)npm run typecheck-- no type errorsnpm run lint-- 0 errors (143 pre-existing warnings)npm run devstarts normally, search works via pg_trgm, healthcheck showselasticsearch: "disabled"ELASTICSEARCH_URL=http://localhost:9200, run ES container, healthcheck showselasticsearch: "connected"