Skip to content

Fixes #37525: Run Elasticsearch semantic search on the shared vector index service - #38415

Merged
manerow merged 35 commits into
mainfrom
agent/can-you-check-if-we-are-addd
Nov 25, 2026
Merged

manerow merged 35 commits into
mainfrom
agent/can-you-check-if-we-are-addd

Conversation

@harshach

@harshach harshach commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes:

Fixes #37525

Semantic search on Elasticsearch embedded only the first chunk of an entity's text. Its vector service never had a chunk index, and several features looked up OpenSearchVectorService.getInstance(), which is null on Elasticsearch. That covered passage search inside an entity, AI-context excerpts, MCP get_entity passages, the staged chunk rebuild during a full reindex, and the reembed CLI. On Elasticsearch, reembed logged "Vector embeddings are disabled" and exited 1.

This PR moves the engine-neutral vector logic out of OpenSearchVectorService into one shared AbstractVectorIndexService, and puts both engines on it. Elasticsearch now gets the chunk index, chunk writes and reuse, passage search, the staged rebuild, and a working reembed. Each engine supplies only six hooks: the engine name, how a request is sent, the chunk index settings, the vector field mapping, the kNN query, and whether a kNN returns at most k hits.

It also records a Java coding rule that review asked for: a method returns once, at the end.

Commits, in order:

  • a980bc5873e chore(search): remove unused VectorSearchUtils
  • 5a57828f57d refactor(search): extract AbstractVectorIndexService from OpenSearchVectorService. A move, so OpenSearch behaviour is unchanged.
  • 6ba6fe258cb feat(search): run Elasticsearch semantic search on the shared vector index
  • d492df1bab2 refactor(search): reach the vector index service through the search repository. This adds the shared EmbeddingEnricher for both bulk sinks.
  • ce9c23b1fea test(search): run the chunk index on real OpenSearch and Elasticsearch
  • 98f4250022f docs(search): say why stored vectors are read by field name
  • e23e41a4caf docs(decisions): record the shared vector index service
  • a5004488f6d docs(agents): a Java method returns once, at the end
  • 29b7789038f refactor(search): give vector index methods a single return
  • a29ffa7e2bd docs(review): review the one-return rule instead of exempting it
  • 012c405350e fix(search): keep entity embeddings when the chunk index cannot be written
  • fdecc08f07c docs(decisions): record how vector chunk failures affect entity embeddings
  • 056e83767dc refactor(search): return once from the staged recreate and reembed entry points
  • e9ce1d1c82f fix(search): never promote a staged chunk generation that missed a write
  • e4a809cc969 fix(search): keep chunk failures from being lost or blocking entity updates
  • 40135dfd528 fix(search): write the chunk header only after the rest of the set
  • 156561d14fd refactor(search): return once from the partition worker
  • f24a28f1f13 fix(search): load the LLM configuration in the ops CLI. Found by the end-to-end run below; main has the same bug.
  • e9bcc553e21 fix(search): promote the chunk generation with the entity indexes
  • 49e03c798a4 fix(search): count and retry chunk writes a reindex misses
  • 3384acf6419 docs(decisions): the chunk generation goes live with the entity indexes
  • 1243345f13a test(search): compare the failed-delete scenario with the live chunks it started from
  • 21245f6686a fix(search): fail a partition that lost a staged chunk delete without a retry
  • ee2e71dedd9 fix(search): keep every stored chunk id within the header's count
  • dd38d5af86d docs(decisions): the chunk header's count bounds every stored chunk id
  • ff67ebc7d75 fix(search): retry an entity a reindex could not embed and count it once
  • ea4571f02bc docs(decisions): retry a missed fresh embed, and keep the live chunks when the pre-flight fails
  • 568ca3570fa fix(search): retry only the misses of the partition that finished
  • 6932a1282cc docs(decisions): a miss is retried by the partition that missed it

Type of change:

  • New feature

High-level design:

Shape. VectorIndexService (interface) → AbstractVectorIndexService (Template Method base) → OpenSearchVectorService / ElasticSearchVectorService.

  • The base owns the chunk index lifecycle and mapping, chunk writes, reuse and deletes, staged generations with alias promotion, searchChunksByParent, search with over-fetch and parent grouping, fingerprints, partial updates, and the closed-segment retry.
  • The engine classes shrink from 1998 to 233 lines (OpenSearch) and from 527 to 153 lines (Elasticsearch).
  • Engine-neutral REST. The typed OpenSearch mget and getAlias calls became REST _mget and _alias, so they are shared. They send the same method and path as before.
  • Elasticsearch mapping. Elasticsearch maps embedding as dense_vector with cosine, which matches EsUtils.

Contract. The chunk and staging methods that used to be no-op defaults on VectorIndexService are now abstract, so an engine cannot silently skip them. OpenMetadata callers reach the service through SearchRepository.getVectorIndexService(). Only SearchRepository's wiring names an engine class. The two bulk sinks share EmbeddingEnricher instead of keeping two copies.

Stays OpenSearch-only. The hybrid RRF search pipeline is an OpenSearch feature, and the hybrid query itself is built in Collate. Elasticsearch hybrid search would need its own retriever request behind a new hook, which is out of scope here.

Collate compatibility. Collate uses OpenSearchVectorService.getInstance(), getEmbeddingClient(), HYBRID_PIPELINE_NAME, buildHybridRrfPipelineDefinition, ensureHybridSearchPipeline, VectorIndexService.search(...) and SearchRepository.getVectorIndexService(). All of them keep their signatures. Collate main (d313b8c) was built locally against this branch with mvn clean install -DskipTests -pl '!collate-ui,!collate-dist', plus ai-platform main (89d3983), and every module passed.

Fault isolation. A chunk index that cannot be written no longer costs an entity its own embedding:

  • Reindex reuse path: keeps the spliced vector and logs the chunk failure.
  • Live edit path: still refreshes a stale entity-document embedding and skips only the chunk write. A raw chunk write never goes to a missing index. A rejected chunk bulk, whether a 503 or a 200 with errors:true, no longer blocks the entity-document update.
  • Chunk header last: chunk 0 is written in its own bulk, only after the other chunks and deletes succeed, so a partly applied bulk never moves the header forward.
  • Chunk count bounds the stored chunks: a write that adds chunk ids first writes chunk 0 with the new count and no fingerprint, so a failed write never leaves chunks past the count. A delete also removes, by a query on parentId, chunks a missing or lagging header does not cover, and deletes chunk 0 last. A delete sends nothing to a chunk index that does not exist yet.
  • Staged generation: the chunk generation goes live together with the run's entity indexes, under the same "partial data is better than no data" rule DefaultRecreateHandler applies to them. A missed chunk write (provider error, open circuit, rejected bulk, failed live-edit mirror) never blocks the swap. It is retried once when its partition finishes, then counted as a vector success or failure, with one summary warning per node, and the entity heals on its next edit or reindex. This includes an entity the run embeds afresh (its text changed, or it was never embedded): a provider error or an open circuit indexes it without an embedding, and the retry writes both its entity-document embedding and its chunks to the run's targets. Only the partition that missed an entity retries it, once that partition's writes are flushed, so the retry never runs before the entity's document is written.
  • When the live chunks are kept: an entity type's staged index was not promoted, the new generation is empty while the live one is not, its document count cannot be read, or a staged delete failed, since that would bring a removed entity's chunks back. A failed delete flags the generation with _meta.incompleteChunkWrites once. A node that cannot save that flag fails its partition at once, with no retry, and the coordinator keeps the live chunks for that type. A run whose embedding pre-flight call fails stages no generation and keeps the live chunks; an entity edited during that outage keeps its old chunks live and has no entity-document embedding until a provider call works again, on the partition-end retry or a later run.
  • Known gap: a live-edit mirror or delete that fails outside a partition, racing with promotion, is only partly covered. The decision record states it.

Merge with main (PR #38465). Main added ontology term embeddings inside both engine classes; that code now lives in the base class. OpenSearch keeps ontology chunks in ontology_embeddings_chunks and Elasticsearch keeps the vector on the term document, as ADR:2026-11-23-ontology-terms-have-dedicated-search-indexes decides. One hook, chunksOntologyTerms, carries that difference, and ontology terms are never part of the data-asset chunk generation.

Merge with main (PR #38574). Main stopped the reembed CLI and the 2-argument updateEntityEmbeddings from writing an ontology term's embedding from its working (draft) row, with the same guard in both engine classes. Here that guard sits once in AbstractVectorIndexService.updateEntityEmbeddings, so it covers both engines, and every term write now goes through the release check in OntologyTermSearch.writeCurrentEmbedding. reembed skips term types when it schedules batches. anOntologyTermKeepsItsVectorOnItsTermDocumentAndWritesNoChunk now writes the term through the release-aware overload.

This also changes OpenSearch in that failure case. Before, it dropped the embedding.

Rollout notes for Elasticsearch operators.

  • Provider cost: the first Search Indexing run after upgrade creates the chunk index and makes one provider call per chunk for every vector-indexable entity it covers. An entity whose embedding fails in that run is counted as a vector failure and does not hold back the rest. Later runs reuse the stored chunk vectors and embed only what is missing.
  • Before that run: search keeps working from the entity-document embeddings, but passage search returns nothing for entities that have not been edited or reindexed since the upgrade. This is inferred from the code and was not run.
  • Storage: each chunk becomes its own document with its own vector. Not measured.
  • Elasticsearch 9.3 vectors: new indexes set index.mapping.exclude_source_vectors=true, so stored vectors are read only through a _mget that names embedding. VectorChunkIndexIT counts provider calls to keep that true.

Decision records:

  • New: ADR:2026-11-20-elasticsearch-and-opensearch-share-one-vector-index-service
  • New: ADR:2026-11-20-a-method-returns-once
  • Amended: ADR:2026-11-11-reindex-reuses-an-embedding-only-when-its-fingerprint-matches
  • Amended: ADR:2026-11-11-chunk-llm-context-lists-child-fields-under-columns

Tests:

Use cases covered

  • On Elasticsearch, an entity's chunks are written to the chunk index, and passages of one entity are returned by a kNN query filtered to its chunks.
  • A full reindex stages a new chunk generation, copies unchanged entities' vectors without a provider call, promotes the generation atomically, and drops chunks of entities the run did not index. This holds on both engines.
  • When the chunk index cannot be created, a live edit still refreshes the entity-document embedding, and a reindex keeps the reused vector.
  • Elasticsearch kNN never asks for more than k hits per page.
  • A missed chunk write still promotes the generation with the entity indexes, and the next write heals the entity. A provider outage on a first rebuild still promotes. A failed staged delete keeps the live chunks. All three hold on both engines.
  • A rejected chunk bulk still refreshes the entity document, and the next update rewrites the chunks.
  • A participant that cannot save the delete flag fails its partition at once, with no retry, and the coordinator keeps the live chunks for that type, even if another node later processes the same range.
  • A write that fails after adding chunks leaves none behind once the entity shrinks or is deleted, in the live index and a staged generation, on both engines.
  • A reindex entity whose fresh embed fails (provider error or open circuit) is retried when its partition finishes, gets both its entity-document embedding and its chunks, and is counted once. Another partition of the same type finishing first does not take its miss.
  • On Elasticsearch, a full Search Indexing run and reembed work end to end with sample data (see Manual testing).
  • OpenSearch behaviour is unchanged except in the failure cases above. Its existing unit tests and ITs pass.

Unit tests

  • I added unit tests for the new/changed logic.
  • Files added/updated:
    • ElasticSearchVectorServiceTest: dense_vector mapping, chunk kNN query, error statuses, unwritable chunk index, kNN page size.
    • EmbeddingEnricherTest
    • OpenSearchVectorServiceTest
    • OpenSearchVectorServiceChunkStagingTest
    • StoredEmbeddingReuseTest
    • RecreateWithEmbeddingsTest
    • DistributedJobParticipantTest
    • AIContextBuilderTest
    • GetEntityToolTest
    • both bulk-sink behaviour tests
    • ElasticSearchVectorServiceTest also covers the later fixes: aRejectedChunkBulkStillRefreshesTheEntityDocAndTheNextUpdateRewritesTheChunks (503 and errors:true), aChunkRejectedBesideTheHeaderNeverMovesTheHeaderForward. Each was checked by breaking its fix.
    • ChunkSetBoundTest (12): grow with a failed header, then delete, shrink or rewrite, live and staged. Checked by breaking each part of the fix.
    • The fresh-embed retry: EmbeddingEnricherTest adds aFreshEmbedTheProviderFailsIsRetriedAndWritesTheEntityEmbeddingAndChunks, aFreshEmbedRetriedOnALiveRunWritesToTheLiveIndexes, aFreshEmbedThatFailsAgainCountsOneFailureAndWritesNothing, aRetryThatCannotWriteTheChunksStillWritesTheEntityEmbeddingAndCountsAFailure, anOpenCircuitOnTheFreshPathMakesNoCallAndCountsTheMissOnceAfterTheSkippedRetry, freshEmbedMissesLogOneSummaryWarningAndNoStackTracePerEntity and aRetryLeavesTheMissesOfAnotherPartitionOfTheSameTypePending; PartitionWorkerTest checks the retry gets the partition's own tracker after the flush; ElasticSearchVectorServiceTest adds aReindexRetryMergesTheEmbeddingIntoTheEntityDocAndReportsWhetherItWasWritten. Five breaks of the new path (retry the old way, count an open circuit at once, let the provider error escape, skip the entity-document write, retry every partition's misses) each fail 1 to 6 of them.
    • The promotion rule: aMissedChunkWriteNeverBlocksPromotion, aProviderFailureWithNoLiveChunksStillPromotes, aFailedDeleteBlocksPromotionAndSavesItsFlagOnce, aParticipantThatCannotSaveTheDeleteFlagFailsItsPartitionUntilARetrySavesIt, aTypeWhoseEntityIndexStayedLiveKeepsTheLiveChunks, aChunkCountThatCannotBeReadKeepsTheLiveChunks, plus the retry pass in PartitionWorkerTest and the promotion hook in DefaultRecreateHandlerTest and DistributedSearchIndexExecutorTest.
    • PartitionWorkerTest (34)
    • Tests of deleted Elasticsearch duplicates were removed.
  • Mutation checks:
    • Restoring the OpenSearch singleton lookup in callers, nulling the staged target, removing the dimension rule, or swapping the Elasticsearch dialect failed 13 tests.
    • Breaking only the unwritable-chunk-index live branch fails anUnwritableChunkIndexStillRefreshesTheEntityDocEmbedding.
    • Flipping knnReturnsAtMostK fails the page-size test with expected: <5> but was: <22>.
    • Disabling the empty-generation guard fails 2 tests, and removing the retry call fails PartitionWorkerTest.
  • Coverage %: not measured with jacoco on this branch.
  • Other suites run locally, all green:
    • 749 unit tests across the vector package, both bulk sinks, EmbeddingEnricherTest, DistributedJobParticipantTest, SearchRepositoryBehaviorTest, AIContextFinderTest, AIContextBuilderTest, RecreateWithEmbeddingsTest, VectorSearchResourceTest, SystemRepositoryEmbeddingsValidationTest and SemanticMemoryDuplicateFinderTest. These ran at 29b7789038f, before the fix commit; the focused run below is at the head.
    • 99 MCP tests: GetEntityToolTest, SemanticSearchToolTest, CompanyContextToolTest.
    • After the review fixes: 564 unit tests across 38 classes, including PartitionWorkerTest, at 156561d14fd; 30 OpenMetadataOperations*Test tests at f24a28f1f13.
    • After the promotion change: 531 focused unit tests across the vector package, EmbeddingEnricherTest, both bulk sinks, PartitionWorkerTest, DistributedJobParticipantTest, DistributedSearchIndexExecutorTest, DistributedReindexFinalizerTest, EntityCompletionTrackerTest, RecreateWithEmbeddingsTest and the DefaultRecreateHandler tests.
    • After the chunk count fix: 683 focused unit tests across the vector package, EmbeddingEnricherTest, both bulk sinks, PartitionWorkerTest, DistributedJobParticipantTest, DistributedSearchIndexCoordinatorTest, DistributedSearchIndexExecutorTest, RecreateWithEmbeddingsTest and the DefaultRecreateHandler tests.
    • After merging main with PR #38574: 513 unit tests across 39 classes (the vector package, RecreateWithEmbeddingsTest, OpenMetadataOperations*Test and both bulk sinks) at 86b74818724.
    • After the fresh-embed retry: 689 focused unit tests on the same set, at 568ca3570fa.
    • After merging main and the delete fix: 910 focused unit tests on the same set plus OntologyTermIndexTest, OntologyReleaseDAOTest, SearchSourceBuilderFactoryTest and SearchRepositoryBehaviorTest, at 354be26d508. ChunkSetBoundTest adds aDeleteBeforeTheChunkIndexExistsSendsNothingToIt, which fails without the fix; ElasticSearchVectorServiceTest adds anOntologyTermKeepsItsVectorOnItsTermDocumentAndWritesNoChunk.

Backend integration tests

  • I added integration tests in openmetadata-integration-tests/.
  • Files added/updated: VectorChunkIndexIT. It starts OpenSearch 3.4.0 and Elasticsearch 9.3.0 containers and runs the same scenarios on each. aMissedChunkWriteStillPromotesAndTheNextWriteHealsIt, aProviderOutageOnAFirstRebuildStillPromotes and aFailedDeleteKeepsTheLiveChunks cover the promotion rule; aGrowthWhoseHeaderFailedLeavesNoChunkBehind covers the chunk count; aRetriedEmbeddingMergesIntoTheIndexedEntityDocument covers the write the fresh-embed retry makes. The class passes 6/6 on both engines at ea4571f02bc; the two later commits do not touch the vector service.
  • After merging main: VectorChunkIndexIT and main's OntologyTermSearchIT pass on -Pmysql-elasticsearch (20 run, 2 OpenSearch-only skips) and -Ppostgres-opensearch (20 run, none skipped). VectorChunkIndexIT passes 6/6 on each engine again at 354be26d508.
  • Also run locally before the fix commit, all green:
    • VectorChunkIndexIT, StoredEmbeddingReuseIT, OpenSearchVectorReaderIT: 6/6 on -Pmysql-elasticsearch and 6/6 on -Ppostgres-opensearch.
    • VectorEmbeddingIntegrationIT, PatchTableEmbeddingIT: 11 run, 1 skipped on each profile.
  • PatchTableEmbeddingIT skips on both lanes, so it verified nothing:
    • Elasticsearch: it skips by its own assumption.
    • OpenSearch: TestSuiteBootstrap.withNaturalLanguageSearch names no embedding provider.
    • None of those files change here.
  • Not run locally: the 16 nightly scale-it and JavaUIIT classes the planner lists in the details comment.

Local Java test run: PASSED

  • Commit: 012c405350ec (base origin/main)
  • Finished: 2026-11-21 06:44 UTC · 4.2 min
  • Scope: focused; merge readiness is not established. Broader steps deferred: 10 (run --scope full).
Step Scope Classes Tests Failed Skipped Min Result
unit openmetadata-mcp (2 classes), openmetadata-service (15 classes) 17 414 0 0 1.3 passed
integration mysql-elasticsearch · parallel 2 4 0 0 2.9 passed
  • Impacted, not run locally: 16 classes (listed in the details)

The block above is from 012c405350e. The later commits were verified by the focused runs listed in this section, not by a new planner run.

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

  • End to end on Elasticsearch, at 156561d14fd plus f24a28f1f13 for reembed. Local Docker stack: Elasticsearch, MySQL, SEMANTIC_SEARCH_ENABLED=true, EMBEDDING_PROVIDER=djl (all-MiniLM-L6-v2, 384 dims, no keys).
    • Sample data ingestion: 1006 records, 99.43% success. Live chunk writes covered 558 entities, and 319 table documents got embeddings.
    • Full Search Indexing run (entities: all) through the real sink and enricher: 1097/1097 records, vector stats 558/558, no vector errors. It staged …_chunks_g1795280135605 and promoted it: "Promoted staged chunk index" and "promotion finished, status -> COMPLETED (allPromoted=true)". The promoted generation covers all 558 entities and has no incompleteChunkWrites flag.
    • Semantic search (POST /api/v1/search/vector/query, "customer shipping addresses") returns the shopify tables, dim_address among them, at about 0.78.
    • reembed first failed with "Bedrock configuration is required when using bedrock provider": the CLI never loaded the LLM configuration. Fixed in f24a28f1f13. After it, 558 entities across 30 types re-embedded with 0 failures. Per-entity chunk counts were identical before and after.
    • A glossary term created after promotion wrote its chunk into the promoted generation through the alias, and GET /api/v1/ai/context/find returned it. Sample data has no glossaries or metrics, so the term was added by hand.
  • An Elasticsearch 9.3.0 probe container confirmed these behaviours:
    • exclude_source_vectors keeps vectors out of a plain get or search, and a request that names the field returns them.
    • A scripted update and a doc-merge update both keep the vector.
    • The clear script removes it.
  • End to end on Elasticsearch 9.3 with a flaky provider, twice: at 21245f6686a (an independent run) and at the final head 6932a1282cc (also run at ea4571f02bc, with the same results). Setup: MySQL 8.0, Elasticsearch 9.3.0, the server run from the branch, an OpenAI-compatible stub (64 dimensions) whose failures can be switched on, 200 tables and 8 glossary terms, and Search Indexing with entities: all (a staged recreate).
    • Healthy run: both heads promote the new generation with vector stats 225/225 and one provider call (the pre-flight).
    • Upgrade case (live chunk generation deleted with the server stopped, then 5% 429s): both heads promote. 22 entities missed, the retry recovered 20, 2 count as vector failures, one summary warning and no stack trace per entity.
    • Changed entities (all 200 descriptions edited during an outage, then 5% 429s): at 21245f6686a, 19 tables failed with one warning and stack trace each, were not retried, and 181 of 200 had chunks. At 6932a1282cc, 16 entities missed, the retry recovered 15 and 1 counts as a vector failure, with one summary warning and no stack trace per entity. 199 of 200 tables have both a current entity embedding and all their chunks, and the next healthy run makes it 200 of 200.
    • Deletes at 6932a1282cc: a soft and a hard delete remove the chunks from the live alias and from vector search. With extra chunk ids indexed past the header's count, a soft and a hard delete leave no chunk with that parentId in the live alias, and a hard delete during a run leaves none in the staged generation, which is then promoted. At 21245f6686a, a staged delete that a write block made fail kept the live chunks.
    • Pre-flight outage: no generation is staged and the chunk alias does not move. At 6932a1282cc, the 195 tables edited during the outage have no entity embedding while their old chunks stay live; the run makes no provider call and logs one summary warning (195 missed, 0 recovered). The next healthy run promotes a new generation with all 197 tables current.
  • Collate main compiled against this branch, as described under High-level design.
  • Not done: the same end-to-end run on OpenSearch. Its path is unchanged apart from the failure handling above.

Follow-ups

  • Hybrid/RRF stays OpenSearch-only (SearchRepository.getHybridRrfPipelineDefinition() and pipeline setup). A working vector service on Elasticsearch is not hybrid-search parity; a future neutral hybrid capability should say which engines support it.
  • reembed and the CLI reindex have no automated test. The CLI config loader reads the database, so a unit test cannot call it, and a forked-CLI IT needs an embedding model or would re-embed the suite's shared index.

UI screen recording:

Not applicable: backend-only change with no UI impact.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed. (No schema changes.)
  • For a UI feature or feature task: as part of PR creation, I ran the PR build in Docker with sample data and embedded a verified GitHub-hosted recording plus build/health evidence above (or explained why this requirement is not applicable). (Not applicable: backend-only.)
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Self-review: I reviewed the final diff against REVIEW.md (the pr-checklist skill runs it) and fixed every 🔴 finding, or answered it on the line below.
    • Commit reviewed: 012c405350e, the second pass.
    • First pass at 29b7789038f, two 🔴, both fixed:
      • A chunk-index failure dropped entity embeddings on Elasticsearch. Fixed in 012c405350e.
      • REVIEW.md still exempted the one-return rule. Fixed in a29ffa7e2bd.
    • Second pass: no 🔴. Its 🟡 are left as follow-ups:
      • An unwritable chunk index makes a live edit embed every chunk to refresh the entity document, which needs only chunk 0. generateEmbeddingFields would cost one call.
      • The enricher's provider-throws-mid-reindex branch lost its only test. Still open, under Follow-ups.
      • reembed on Elasticsearch has no test. It now ran end to end (Manual testing); the automated test is under Follow-ups.
      • Some methods this branch touched outside the vector package still have early returns. RecreateWithEmbeddings, OpenMetadataOperations.reembed and PartitionWorker now return once (056e83767dc, 156561d14fd).
      • The shared-service ADR said OpenSearch is unchanged. fdecc08f07c revised it to record the failure-case change.
      • The reviewer suggested shipping the one-return rule as its own PR. It stays here, because the PR author asked for it on this branch during review.
  • Decision check: if this PR decides something the next contributor could undo — a schema field, REST path or format another component or repo must agree with, a new default or limit, an ordering that must hold, or a rule stated only in this description — it adds a record under docs/decisions/ (see its README.md). This description is gone from git log after the squash-merge.

🤖 Generated with Claude Code


Summary by Gitar

  • Test coverage:
    • Added EntityRepositoryRestoreTest isolation for bulk restore cleanup tests
    • Added VectorChunkIndexIT running chunk-index scenarios on real OpenSearch and Elasticsearch

This will update automatically on new commits.

RetriggerView in GreptileConfidence Score: 4/5

The partition-scoped retry change looks sound, but the outstanding one-return requirement must be satisfied before merging.

Findings

  1. P2 Missed chunks go uncounted ▶
  2. P2 Changed methods retain early returns ▶

Summary

The PR puts Elasticsearch and OpenSearch on one shared vector service. The latest changes keep embedding retries with the partition that recorded each miss.

  • Elasticsearch and OpenSearch store and search text chunks through one vector service.
  • Reindex runs keep entity embeddings when chunk writes fail.
  • AI context and MCP entity views can retrieve passages through either search engine.
  • Java methods now follow one return at the end of the method.

No new findings were accepted.

Diagram

sequenceDiagram
  participant Worker as PartitionWorker
  participant Sink as Bulk sink
  participant Misses as MissedChunks
  participant Vector as VectorIndexService
  Worker->>Sink: Write batch with partition tracker
  Sink->>Misses: Record failed embedding or chunks with tracker
  Worker->>Sink: Flush partition writes
  Worker->>Sink: retryMissedChunks(tracker)
  Sink->>Misses: Drain only matching tracker
  Misses->>Vector: Retry missed writes
  Sink->>Sink: Count results and flush stats
  Worker->>Worker: Complete partition
Loading

Reviews (16) · Last reviewed commit: "docs(decisions): a miss is retried by th..." · Reviewed by Greptile

No main or test code calls updateVectorEmbeddingsForOpenSearch. The class
predates VectorEmbeddingHandler, which owns the entity-update write path.
…ectorService

Move the engine-neutral vector index logic into a Template Method base:
the chunk index lifecycle and mapping, chunk writes and deletes, staged
generations and promotion, embedding reuse, parent-grouped search and
the retry on closed segments. OpenSearchVectorService keeps the hybrid
RRF pipeline and supplies six hooks: the raw request, the engine name,
the index settings, the vector field mapping, the kNN search body and
whether a kNN is bounded by k.

The typed mget and getAlias calls become REST JSON through the request
hook (POST /{index}/_mget, GET /{base}/_alias), so the base needs no
OpenSearch client. Requests, mapping and retries are unchanged.

legacyEmbeddingFields moves to VectorDocBuilder, next to the chunk docs
it reads. The unused three-argument searchChunksByParent is removed.
…index

ElasticSearchVectorService extends AbstractVectorIndexService and
supplies only its dialect: the Rest5Client request, the dense_vector
mapping and the native top-level knn search. Elasticsearch gains the
chunk index and its staged recreate, chunk writes and deletes, passage
search by parent, and the provider-availability gate on entity updates.
Stored-embedding reuse now reads with _mget, as OpenSearch does. A
failed request reports "Elasticsearch generic request failed" with the
status and body in the cause, the shape OpenSearch already had.

VectorIndexService declares these capabilities as required methods in
place of no-op defaults, so an engine cannot silently skip them.
search(VectorSearchParameters) becomes the one abstract search and the
positional overloads delegate to it.

Elasticsearch tests that repeated the OpenSearch tests of the now-shared
search grouping are removed. New tests pin the Elasticsearch dialect:
the dense_vector chunk mapping and the knn search filtered to a parent.
…epository

Reindex, the re-embed command, AI context excerpts and the MCP entity tool
asked OpenSearchVectorService.getInstance() for the vector service. That is
null on Elasticsearch, so each of them did nothing there, and re-embed
exited 1 reporting that embeddings were disabled.

They now use SearchRepository.getVectorIndexService(), which holds the
service of whichever engine is configured. SearchRepository is the only
class left in main code that names an engine's vector service.

The two reindex bulk sinks carried separate copies of the embedding step.
Both now call EmbeddingEnricher, which keeps the OpenSearch behaviour. On
Elasticsearch a reindex therefore writes chunk documents, backfills them
for entities whose stored embedding is reused, and during a provider
outage indexes an entity without an embedding instead of counting it as
failed.
The chunk index is shared code, and each engine supplies only its
request dialect. The unit tests mock the HTTP boundary, so they cannot
tell whether a real engine accepts the mapping, the bulk writes, the
kNN search or the alias swap.

VectorChunkIndexIT runs one scenario against a container of each
engine. It writes chunks, reads the passages of one parent and searches
through the alias. Then it stages a full recreate, copies an unchanged
entity into the new generation without a provider call, and promotes
the generation.
Elasticsearch 9.3.0 leaves a dense_vector out of _source unless the
request names the field. The multi-get that reads stored vectors names
it, so reusing a stored vector works on both engines. A comment now
records that. VectorChunkIndexIT fails if the vectors stop coming back.

Also make the totalHits comment engine-neutral.
Add the record for running both search engines on one vector index
service. Amend the two 2026-11-11 records that describe Elasticsearch as
embedding chunk 0 only, and remove a guard test that was deleted.
Promote the java.md return guidance from a preference to a rule, state it in
AGENTS.md, and record the decision.
REVIEW.md still told reviewers that a trailing return was only a preference,
which left the new rule with no enforcement.
@harshach
harshach requested a review from a team as a code owner November 21, 2026 06:51
@harshach
harshach requested a review from yan-3005 November 21, 2026 06:51
@harshach harshach added the safe to test Add this label to run secure Github workflows on PRs label Nov 21, 2026
Copilot AI balanced review requested due to automatic review settings November 21, 2026 06:51
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

@harshach

Copy link
Copy Markdown
Collaborator Author

Local Java test run: PASSED — details

  • Commit: 012c405350ec (base origin/main)
  • The summary is in the PR description.

Tests run locally

  • unit · openmetadata-mcp (2 classes), openmetadata-service (15 classes): AIContextBuilderTest (52 passed), DistributedJobParticipantTest (18 passed), ElasticSearchBulkSinkBehaviorTest (14 passed), ElasticSearchBulkSinkSimpleTest (6 passed), ElasticSearchVectorServiceTest (22 passed), EmbeddingEnricherTest (9 passed), GetEntityToolTest (43 passed), OpenSearchBulkSinkBehaviorTest (13 passed), OpenSearchVectorServiceChunkStagingTest (10 passed), OpenSearchVectorServiceTest (34 passed), RecreateWithEmbeddingsTest (9 passed), SemanticSearchToolTest (37 passed), StoredEmbeddingReuseTest (18 passed), SystemRepositoryEmbeddingsValidationTest (7 passed), VectorDocBuilderChunkTest (19 passed), VectorDocBuilderTest (45 passed), VectorSearchQueryBuilderTest (58 passed)
  • integration · mysql-elasticsearch · parallel: OpenSearchVectorReaderIT (2 passed), VectorChunkIndexIT (0 passed), VectorChunkIndexIT$OnElasticsearch (1 passed), VectorChunkIndexIT$OnOpenSearch (1 passed)

Per-class counts come from the test reports, which can credit a test to the wrong class when classes run concurrently, and keep only the last run of a nested class that several test classes inherit. The summary's step totals are Maven's own counts.

Broader coverage not executed by this focused run

  • mvn -B package -pl openmetadata-mcp,openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=AIContextBuilderTest,AIContextFinderTest,AIContextMarkdownTest,AlertingArchitectureTest,AppConfigurationSettingTest,AvailableEntityTypesConsistencyTest,BasicAuthenticatorEmailFailureTest,BasicAuthenticatorTokenTest,ClasspathScanIndexTest,CompanyContextToolTest,ContextMemoryBodyTextContributorTest,DistributedIndexingStrategyTest,DistributedJobParticipantTest,DistributedReindexFinalizerTest,DistributedSearchIndexExecutorTest,ElasticSearchBulkProcessorConnectionPoolTest,ElasticSearchBulkProcessorTest,ElasticSearchBulkSinkBehaviorTest,ElasticSearchBulkSinkColumnBackpressureTest,ElasticSearchBulkSinkSimpleTest,ElasticSearchVectorServiceTest,EmailUtilBaseUrlTest,EmbeddingEnricherTest,EntityCsvTest,EntityRepositoryCertificationTest,GetEntityToolTest,GovernedDefinitionTest,HonestResponseTest,IndexTemplateManagerTest,MetricRepositoryTest,MintedTokensAreRecognizedTest,NotificationTemplateHelperAdvancedTest,OntologyEntityDAOTest,OpenMetadataOperationsDeployPipelinesTest,OpenMetadataOperationsJwksTest,OpenMetadataOperationsSettingsSourceTest,OpenMetadataOperationsSmartReindexTest,OpenSearchBulkProcessorConnectionPoolTest,OpenSearchBulkProcessorTest,OpenSearchBulkSinkBehaviorTest,OpenSearchBulkSinkColumnBackpressureTest,OpenSearchBulkSinkSimpleTest,OpenSearchBulkSinkStatsTest,OpenSearchVectorMemoryAccessTest,OpenSearchVectorServiceChunkStagingTest,OpenSearchVectorServiceRequestTest,OpenSearchVectorServiceTest,PageBodyTextContributorTest,PersonaContextBuilderTest,RecreateWithEmbeddingsTest,ReindexingOrchestratorTest,RuleEngineTest,SearchRepositoryBehaviorTest,SearchRepositoryTest,SearchSettingsMergeUtilRepositoryResolutionTest,SeedDataGateTest,SemanticMemoryDuplicateFinderTest,SemanticSearchToolTest,SettingsCacheColumnIndexingTest,SettingsCacheDefaultCaseTest,SettingsCacheInvalidationTest,SettingsSnapshotTransactionHandlerTest,SettingsSourceServiceTest,StoredEmbeddingReuseTest,SystemRepositoryCreateNewSettingTest,SystemRepositoryEmbeddingsValidationTest,SystemRepositoryLdapStatusTest,SystemRepositoryLlmProviderValidationTest,SystemRepositoryMissingIndexesTest,SystemRepositoryPatchSettingTest,SystemRepositoryReindexStatusTest,SystemRepositorySecurityConfigPatchTest,SystemRepositorySecurityConfigValidationTest,SystemRepositorySecuritySettingsTest,SystemRepositorySlackAppSettingTest,SystemRepositorySystemBotsTest,SystemRepositoryTokenValidityTest,SystemResourceSecurityConfigApplyTest,SystemResourceSettingsAuthorizationTest,TestCaseSearchMaskerTest,UserUtilTest,VectorDocBuilderChunkTest,VectorDocBuilderTest,VectorDocBuilderTopicFieldsTest,VectorEmbeddingHandlerTest,VectorSearchQueryBuilderTest,VectorSearchResourceTest,WorkflowHandlerSchemaUpdateTest -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel '-Dit.test=<161 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=global-state -Dit.test=AppsResourceIT,ContextMemoryDerivationIT,ContextMemoryExtractionIT,ContextMemoryExtractionRequestIT,ConversationSchemaMigrationIT,DataContractValidationAppIT,EntityShapeIT,MetricMigrationIT,OpsRegenerateBotTokensIT,SearchIndexRetryQueueIT,SsoSecurityConfigApplyIT,SystemResourceIT,TestSuiteReindexIT,UserMetricsResourceIT,VectorEmbeddingIntegrationIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=rdf -Dit.test=AgentSparqlResourceIT,RdfFirstIndexRunIT,RdfIndexAppScaleIT,RdfIndexRunRecoveryIT,RdfMcpKnowledgeGraphIT,RdfReindexFailuresIT,RdfReindexInsertOnlyIT,RdfReindexRunLockIT,RdfSemanticSearchIT,RdfSoftDeleteReindexIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Psearch-it -DdatabaseType=mysql -DsearchType=elasticsearch -Djpw.data.mode=ingest '-Dit.test=<31 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pcache-tests -DintegrationTests.lane=parallel -Dit.test=BundleWarmupCertificationIT,EntityCacheWriteOrderIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Ppostgres-opensearch -DintegrationTests.lane=parallel '-Dit.test=<62 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Ppostgres-opensearch -DintegrationTests.lane=global-state -Dit.test=AppsResourceIT,ContextMemoryExtractionIT,DataContractValidationAppIT,PatchTableEmbeddingIT,SearchIndexRetryQueueIT,TestSuiteReindexIT,VectorEmbeddingIntegrationIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Ppostgres-opensearch -DintegrationTests.lane=rdf -Dit.test=RdfFirstIndexRunIT,RdfIndexAppScaleIT,RdfIndexRunRecoveryIT,RdfReindexFailuresIT,RdfReindexInsertOnlyIT,RdfReindexRunLockIT,RdfSemanticSearchIT,RdfSoftDeleteReindexIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Psearch-it -DdatabaseType=postgres -DsearchType=opensearch -Djpw.data.mode=ingest '-Dit.test=<32 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
Impacted, not run locally (16)
  • LineagePayloadScaleIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • LineageScenePerformanceScaleIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • OntologyScaleIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • ReindexBenchmarkIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • ReindexCpuHeadroomIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • Scale100kEntitiesIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • ServiceDeleteSearchCleanupScaleIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • TableTotalCountScaleIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • EntityLoaderSmokeUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • LongCompoundNameSearchUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • PipelineOwnerIndexUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • DistributedAutoTuneReindexUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • SearchAvailableAllKindsDuringReindexUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • SearchAvailableDuringReindexUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • SelectiveFieldReindexUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • SimpleReindexTriggerUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
Commands
mvn -B package -pl openmetadata-mcp,openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=AIContextBuilderTest,DistributedJobParticipantTest,ElasticSearchBulkSinkBehaviorTest,ElasticSearchBulkSinkSimpleTest,ElasticSearchVectorServiceTest,EmbeddingEnricherTest,GetEntityToolTest,OpenSearchBulkSinkBehaviorTest,OpenSearchVectorServiceChunkStagingTest,OpenSearchVectorServiceTest,RecreateWithEmbeddingsTest,SemanticSearchToolTest,StoredEmbeddingReuseTest,SystemRepositoryEmbeddingsValidationTest,VectorDocBuilderChunkTest,VectorDocBuilderTest,VectorSearchQueryBuilderTest -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel -Dit.test=OpenSearchVectorReaderIT,VectorChunkIndexIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@mohityadav766 mohityadav766 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 012c405350ec94486754dfd5deb638f42552cdf1, including the shared vector lifecycle, bulk-sink enrichment, passage/MCP callers, reindex callbacks and CLI wiring.

The shared implementation closes the Elasticsearch chunk/passages/service-lookup gaps. The live-update fault-isolation issue in the existing thread still needs fixing before merge; I added the specific missing regression cases there rather than opening a duplicate finding. I also left a separate lifecycle follow-up on suppressed staged-chunk failures, explicitly distinguishing inherited behavior from a new OpenSearch regression.

Scope/acceptance follow-ups:

  • Hybrid/RRF remains OpenSearch-specific in SearchRepository.getHybridRrfPipelineDefinition() and pipeline initialization. This is correctly outside this PR's stated scope; successful vector-service initialization must not be treated as evidence of full hybrid-search parity. Any future neutral hybrid capability/settings contract should distinguish those capabilities explicitly.
  • Before declaring the new Elasticsearch operations supported end to end, exercise a full Search Indexing run through the actual sink/enricher and reembed on ES. The isolated chunk-generation IT does not cover those entry points. The PR already acknowledges the CLI and provider-throws coverage gaps; please retain them as explicit follow-ups.

This was source/test inspection; I did not independently run the reported test suites.

…dings

An unwritable chunk index keeps the entity's document embedding on both
engines, which changes earlier OpenSearch behavior. A failed chunk write
during a staged recreate does not block promotion; that gap came from the
OpenSearch implementation and is recorded as a revisit trigger.
…try points

recreateChunkIndexIfFullRun and the reembed command were edited by this
branch, so they follow the one-return rule. reembed moves its setup, batch
scheduling and summary into helpers that share one ReembedRun record.
Copilot AI balanced review requested due to automatic review settings November 21, 2026 15:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

A failed chunk write, mirror or delete into a staged generation was logged
and the run still promoted the generation once every entity type
finalized, so a rebuild could replace a complete chunk index with one that
had lost chunks. The failing node now sets _meta.incompleteChunkWrites on
that generation's index, and the coordinator reads it before the alias
swap. The flag lives on the cluster, so a participant's failure blocks the
coordinator's promotion and stays tied to the generation it hit.

VectorChunkIndexIT rejects one bulk item on OpenSearch and Elasticsearch,
checks the old chunks stay live, and checks a clean retry promotes.
Copilot AI balanced review requested due to automatic review settings November 21, 2026 15:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 23, 2026 12:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 24, 2026 07:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 25, 2026 07:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@gitar-bot

gitar-bot Bot commented Nov 25, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🔴 High risk 10 closed / 10 findings

Staged vector-generation promotion and chunk deletion alter stored search data; a coordination or cleanup error could expose stale vectors or omit valid passages.

Shares one vector index service between Elasticsearch and OpenSearch, so Elasticsearch now gets chunk indexing, passage search, staged chunk rebuilds, and a working reembed. Recent fixes address chunk-failure handling, promotion of staged generations, and retry of missed embeddings per partition. No open findings remain, and the review is approved.

✅ 10 closed
✅ Quality: ADR says OpenSearch is unchanged, but this PR changes its chunk-failure path

📄 docs/decisions/2026-11-20-elasticsearch-and-opensearch-share-one-vector-index-service.md:61-62 📄 openmetadata-service/src/main/java/org/openmetadata/service/search/vector/AbstractVectorIndexService.java:199-209 📄 openmetadata-service/src/main/java/org/openmetadata/service/search/vector/AbstractVectorIndexService.java:261-275
The new record 2026-11-20-elasticsearch-and-opensearch-share-one-vector-index-service.md:61-62 says "OpenSearch is unchanged. It sends the same requests, creates the same mappings and retries the same way." Commit 012c405 changes how OpenSearch behaves. Before it, refreshEntityEmbeddings called requireChunkIndexForWrite() first, so an unwritable chunk index threw and the stale entity-doc embedding was never refreshed. Now isChunkIndexWritable() sends that case to refreshEntityDocOnly (lines 265-275). backfillChunksToLiveIndex (lines 203-209) now catches the failure, so EmbeddingEnricher.enrich keeps the spliced embedding. Before, the enricher returned the doc without it and counted a failed vector record.

The description says this outright: "On OpenSearch, an unwritable chunk index now keeps the entity embedding, which changes previous behavior that dropped it." Nothing under docs/decisions/ states that rule, and the Accepted record says the opposite. Since the repo squash-merges, the record is the only place this will survive. Add a Decision bullet along the lines of: "A chunk index that cannot be written never costs an entity its document embedding: a live edit refreshes only the stale entity-doc embedding and skips the chunk write, a reindex keeps the spliced embedding and logs the chunk failure, and no raw chunk write goes to a missing index." Then rewrite the "OpenSearch is unchanged" consequence to name this exception.

✅ Quality: Touched methods still break the one-return ADR added in this PR

📄 openmetadata-service/src/main/java/org/openmetadata/service/search/RecreateWithEmbeddings.java:58-72 📄 openmetadata-service/src/main/java/org/openmetadata/service/util/OpenMetadataOperations.java:1796-1799 📄 docs/decisions/2026-11-20-a-method-returns-once.md
2026-11-20-a-method-returns-once.md is Accepted in this PR. It says "a change that touches a method brings it into line", and REVIEW.md now treats a changed production method with more than one return as a finding. This PR edits RecreateWithEmbeddings.recreateChunkIndexIfFullRun (line 59). That method still has three returns: a guard return null, an early return vectorService.beginStagedChunkRecreate() and a trailing return null. The PR also edits the reembed command in OpenMetadataOperations (line 1796), and that method keeps its guard return 1; right after the changed line.

The description puts these off to a follow-up, but the record the PR adds sets no such exception. Either rewrite these methods to return once, or add a sentence to the ADR that exempts the named methods until the follow-up lands.

✅ Quality: isStagedGenerationIncomplete returns inside try, against the one-return ADR

📄 openmetadata-service/src/main/java/org/openmetadata/service/search/vector/AbstractVectorIndexService.java:645-658
ADR:2026-11-20-a-method-returns-once says a method has at most one return and that it is the last statement. isStagedGenerationIncomplete instead returns from inside the try, and its last statement is the try/catch. In the same commit, deleteChunksFrom was rewritten with a result variable and a trailing return, so this new method breaks the rule the branch is applying. Assign the result to a local inside the try and return it after the catch.

✅ Edge Case: Coordinator chunk failure skips the blocked-promotion warning

📄 openmetadata-service/src/main/java/org/openmetadata/service/search/vector/AbstractVectorIndexService.java:585-587 📄 openmetadata-service/src/main/java/org/openmetadata/service/search/vector/AbstractVectorIndexService.java:612-620 📄 openmetadata-service/src/main/java/org/openmetadata/service/search/vector/AbstractVectorIndexService.java:666-669 📄 docs/decisions/2026-11-20-elasticsearch-and-opensearch-share-one-vector-index-service.md:73-76
When a chunk write fails on the coordinator, markStagedGenerationIncomplete sets stagedChunkRunFailed = true. Because of that flag, markEntityTypeReindexed skips its !stagedChunkRunFailed && containsAll(...) branch and never calls promoteStagedChunkIndex. Two things follow:

  • The "promotion blocked" warning is never logged, although the updated ADR names that warning as one of the two signals for this case.
  • stagedChunkIndex is never cleared, so until the next staged recreate the coordinator keeps mirroring every live edit into the abandoned generation.

Fix: let markEntityTypeReindexed call promoteStagedChunkIndex whenever all expected types have completed. Its existing under-lock re-check already blocks on stagedChunkRunFailed or the _meta flag, logs the warning and clears stagedChunkIndex.

✅ Edge Case: Partial chunk bulk failure updates the header, so the next edit skips the rewrite

📄 openmetadata-service/src/main/java/org/openmetadata/service/search/vector/AbstractVectorIndexService.java:297-311 📄 docs/decisions/2026-11-20-elasticsearch-and-opensearch-share-one-vector-index-service.md:65-66
writeLiveChunks and the new ADR bullet assume that a failed chunk write "leaves the old chunk header in place", so the next update sees stale chunks and rewrites them. A _bulk that returns 200 with errors:true is not atomic, though. If item <parentId>_0 succeeds and a later chunk (say _3) is rejected with a 429, chunk 0 ends up with the new fingerprint, chunkCount and docVersion. The next updateEntityEmbeddings then reads that header through getChunkHeader (a GET of _0), computes ChunkRefresh.NONE, and the missing chunk stays missing until the entity's content changes. The parameterized test only uses a single-item failure, which hides this case. One fix is to write chunk 0 last, in a second request sent only after every other item succeeds. Another is to re-index or delete _0 with the previous header when any item fails, so the header only moves forward once the whole chunk set is written.

...and 5 more closed from earlier reviews

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Elasticsearch embeds only the first chunk of an entity's text

6 participants