feat(search): migrate unified search from Elasticsearch to PostgreSQL FTS pipeline#209
feat(search): migrate unified search from Elasticsearch to PostgreSQL FTS pipeline#209
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6bf2d022e9
ℹ️ 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".
|
|
||
| //time stamp 리스트에 추가 | ||
| redisTemplate.opsForList().rightPush(LIST_KEY_PREFIX + keyword, String.valueOf(now)); | ||
|
|
There was a problem hiding this comment.
Guard search-log writes so detail search still succeeds
recordSearch now performs a PostgreSQL insert on the request path without handling failures. If search_query_log is not yet migrated or the DB write fails transiently, this exception bubbles out of /api/v1/search/detail after search results are computed, turning successful searches into 500s. This logging path should be best-effort (catch/log and continue) so analytics outages do not break user-facing search.
Useful? React with 👍 / 👎.
| } | ||
|
|
||
| public void rebuildSearchDocuments(List<SearchWriteModel> rows) { | ||
| jdbcTemplate.update("TRUNCATE TABLE thingo_search_document", new MapSqlParameterSource()); |
There was a problem hiding this comment.
Make table rebuild atomic to avoid empty search index
rebuildSearchDocuments truncates thingo_search_document before repopulating it, but this destructive step is not wrapped in a transaction with the subsequent batch insert. Any mid-rebuild failure (constraint error, timeout, connection drop) can leave the table empty or partially loaded, causing a broad search outage until a manual rerun. The truncate+insert path should run atomically (or use a staged swap).
Useful? React with 👍 / 👎.
Motivation
tsvectorweights and SQL ranking formulas suitable for Korean text and operational constraints.Description
PostgresUnifiedSearchRepositorythat implements unified search, autocomplete and top-keywords using PostgreSQL FTS and ranking SQL; file:src/main/java/nova/mjs/domain/thingo/ElasticSearch/Repository/PostgresUnifiedSearchRepository.java.UnifiedSearchServicenow delegates to the Postgres repository while preserving the existingsearch(keyword, type, category, order, pageable)API; file:src/main/java/nova/mjs/domain/thingo/ElasticSearch/Service/UnifiedSearchService.java.SearchIndexSyncServiceto build a fullthingo_search_documenttable in Postgres from domain repositories and refresh FTS vectors instead of creating ES indices; file:src/main/java/nova/mjs/domain/thingo/ElasticSearch/Service/SearchIndexSyncService.java.SuggestServiceto call the Postgres autocomplete SQL ranking (personal/global/time-decay) and updatedRealtimeKeywordServiceto persist search logs to Postgres while retaining Redis ZSET behavior for hot cache/fallback; files:SuggestService.java,RealtimeKeywordService.java.src/main/resources/db/search/postgres_search_schema.sqland documented the migration, architecture, ranking and verification plan indocs/postgresql-search-migration-plan.md.Testing
./gradlew compileJavato validate compilation, but the build could not run in this environment due to a Gradle/JDK incompatibility reportingUnsupported class file major version 69(build did not complete).Codex Task