Repository navigation
Fixes #38516: Engine-neutral building blocks for hybrid search - #38517
Conversation
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.
…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.
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.
…pdates - A live edit whose chunk bulk fails, by HTTP error or by an item error in a 200, still refreshes the entity document's embedding. The old chunk header stays, so the next update rewrites the chunks. - A finalized run always goes through promotion, which re-checks the failure flags under the lock. A coordinator-side chunk failure now logs the blocked promotion and clears the staged state. - A node that cannot save the incomplete flag retries it when a vector-type partition ends and fails the partition if it still cannot, so the coordinator fails the entity type and keeps the old chunks. - isStagedGenerationIncomplete returns once.
A bulk request is not atomic. When chunk 0 was written beside a chunk the cluster rejected, the header moved forward and the next update skipped the rewrite, so the missing chunk stayed missing. Chunk 0 is now written in its own request after every other chunk and delete succeeded. requireStagedChunkFailuresRecorded is abstract, like the other staging methods on VectorIndexService. The shared-service ADR records that a live edit's mirror or delete into a staged generation is covered only in part.
processPartitionInternal had four returns. It now chooses between a skipped and a started partition, and processStartedPartition returns one result after reading the range (readPartition) and finishing it (finishPartition). The moved code is unchanged apart from the counters, which travel together as PartitionCounts.
reembed and the CLI reindex resolved the embedding provider from LlmConfigHolder, which only server startup filled. The CLI therefore fell back to bedrock and refused to embed under any other provider.
… when the pre-flight fails
UI browser testsRan: all test files (no impact map from main yet) Result: ✅ 1070 passed · 154 skipped |
…er stops using it
…downstream caller
The base branch was changed.
# Conflicts: # docs/decisions/2026-11-20-elasticsearch-and-opensearch-share-one-vector-index-service.md # openmetadata-service/src/main/java/org/openmetadata/service/search/vector/AbstractVectorIndexService.java # openmetadata-service/src/main/java/org/openmetadata/service/search/vector/ElasticSearchVectorService.java # openmetadata-service/src/main/java/org/openmetadata/service/search/vector/OpenSearchVectorService.java # openmetadata-service/src/main/java/org/openmetadata/service/search/vector/VectorIndexService.java # openmetadata-service/src/test/java/org/openmetadata/service/search/vector/ChunkSetBoundTest.java # openmetadata-service/src/test/java/org/openmetadata/service/search/vector/ElasticSearchVectorServiceTest.java
Code Review ✅ Approved 🟡 Medium risk 1 closed / 1 findingsNew Elasticsearch vector options change index construction, and engine-specific kNN clauses could change results in caller-built hybrid searches. Adds engine-neutral hybrid search primitives: ✅ 1 closed✅ Edge Case: Public getHybridWeights() NPEs when naturalLanguageSearch is unset
VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Describe your changes:
Fixes #38516
Stacked on PR #38415. Its base is that PR's branch, so this diff shows only this PR's changes. Review and merge after it; once #38415 merges, this PR moves to
main. Merge order: Collate PR #8922, OM PR #38415, this PR, Collate PR #8899, then OM PR #38565. The companion Collate PR is PR #8899, and the benchmark change is PR #2419.I added small, engine-neutral primitives so a caller can build hybrid (keyword plus vector) search
on Elasticsearch as well as OpenSearch. The OpenSearch RRF search pipeline stays exactly as it is
on #38415: Collate main still calls it, so its removal waits until Collate stops using it.
SearchClient.getQueryDsl()returns aSearchQueryDslthat renders OpenMetadata's typed,engine-specific builders as query JSON: one
OMQueryBuilderclause (toJson), and the query/v1/searchruns for a text with the ranking shell of the search settings(
dataAssetQueryJson). Both clients implement it with their own JSON mapper.VectorIndexService.knnQueryClause(vector, parameters)returns the engine's kNN clause,usable inside
boolandfunction_score, through a newbuildKnnQueryClausehook:OpenSearch's
knnclause plusignore_unmapped, and Elasticsearch'sknnquery (kper shard,num_candidatesclamped,similarity = 2 * threshold - 1because Elasticsearch takes the rawcosine while the threshold is on the
(1 + cosine) / 2score scale). This resolves the"Revisit" clause of Fixes #37525: Run Elasticsearch semantic search on the shared vector index service #38415's decision record with a hook, as that record suggested.
SearchRepository.getHybridWeights()exposes the keyword and semantic weights (searchsettings, then config, then 0.6 and 0.4) in one place, including when
naturalLanguageSearchis not configured at all.
SearchSourceBuilderFactory.assetTypeConfiguration(indexName, searchSettings), a staticlookup that
findAssetTypeConfignow delegates to, so a caller that holds no engine factory canuse it instead of copying it.
m48and
ef_construction256, the OpenSearch values, from one helper used by the entity indexes andthe chunk index. A
PUT _mappingon an existing index reads the live mapping first: if theindex already has
embedding, the field is left out of the body, so it keeps the options itwas created with; if it has none yet (embeddings just turned on), the field is added with the
pinned options. Re-declaring an existing field is refused either way: Elasticsearch reads a
dense_vectorwithoutindex_optionsas the engine default and will not change the options ofan existing field, and sending the pinned options is refused on an index created before this PR.
Because
PUT _mappingis atomic, that refusal would drop every new field of an upgrade.OpenMetadata runs a hybrid query or reads the stored
hybrid-rrfpipeline, but Collate mainstill uses
HYBRID_PIPELINE_NAME,buildHybridRrfPipelineDefinition,getHybridRrfPipelineDefinitionandensureHybridSearchPipeline, and OpenMetadata'scompatibility check builds Collate main against every OM PR. Deleting the pipeline here would break that build and deadlock this PR with Collate
PR getting error while connecting snowflake #8899, which needs this PR's new API before it can drop those calls. So this PR keeps every
pipeline member, caller and test exactly as on Fixes #37525: Run Elasticsearch semantic search on the shared vector index service #38415: OpenSearch keeps creating and checking the
pipeline, and the embeddings status still reports it. OM PR Rename AvailableEntityTypes to EmbeddedEntityTypes #38565 deletes it after Collate
PR getting error while connecting snowflake #8899 merges. One small fix stays here: on Elasticsearch, which has no pipeline, the
embeddings status no longer says "hybrid search pipeline" (
usesHybridSearchPipeline).naturalLanguageSearch.hybridSearch.searchPipelineis unchanged in the configuration schema.It is still the pipeline name. After OM PR Rename AvailableEntityTypes to EmbeddedEntityTypes #38565 it stays and is ignored: the block does not
allow unknown keys and Dropwizard fails startup on one, so deleting the key would stop a server
whose configuration file still sets it.
Nothing changes for OpenMetadata's own vector search:
buildQueryandbuildKnnSearchareuntouched, and OpenSearch deployments keep the
hybrid-rrfpipeline exactly as before.Type of change:
High-level design:
The consumer is Collate's hybrid search, which fuses the two legs itself with weighted RRF on both
engines. All engine syntax stays in OpenMetadata next to the clients; the caller composes requests
for
rawSearchRequestwithout naming an engine. Fusion stays out of OpenMetadata.Decision records:
docs/decisions/2026-11-23-search-clients-render-typed-builders-as-query-dsl.md(new)docs/decisions/2026-11-23-elasticsearch-vector-fields-pin-their-index-options.md(new)docs/decisions/2026-11-23-the-hybrid-rrf-pipeline-leaves-openmetadata.md(new; the decisionand why the removal is staged: the deletion ships in OM PR Rename AvailableEntityTypes to EmbeddedEntityTypes #38565)
docs/decisions/2026-11-20-elasticsearch-and-opensearch-share-one-vector-index-service.md(v3amendment)
Tests
OpenSearchQueryDslTest,ElasticQueryDslTest,SearchQueryDslParityTest(the ranking shelland the memory visibility rule are equal on both engines; boost weights compared at float
precision, because the OpenSearch client writes
0.30000001192092896where Elasticsearch writes0.3).VectorSearchQueryBuilderTest(both clause shapes, radial and top-k, the similarity conversion,the caps),
EsUtilsTest(new field pinned, existing field kept, an update leaves out anembeddingthelive index has and adds the pinned one when it has none, a different live dimension fails),
ElasticSearchIndexManagerTest(the live mapping is read through an alias over severalindexes),
ElasticSearchVectorServiceTest,ChunkSetBoundTest.SearchSourceBuilderFactoryTest(new case for the static lookup),SearchRepositoryBehaviorTest.getHybridWeightsReadsTheAdminWeightsOfTheSearchSettings(new; theweights were only tested through the pipeline check before) and
getHybridWeightsFallsBackToTheDefaultsWithoutNaturalLanguageSearchConfiguration(new),SystemRepositoryEmbeddingsValidationTest,ReindexingOrchestratorTest,OpenSearchVectorServiceTest,SystemResource*Test(theirpipeline cases are kept as on Fixes #37525: Run Elasticsearch semantic search on the shared vector index service #38415).
the
search.vector,search.queries,search.elasticsearchandsearch.opensearchpackages plusSearchRepository*Test,SearchSourceBuilderFactoryTest,SystemRepository*Test,SystemResource*Test,ReindexingOrchestratorTest);openmetadata-integration-testscompiles(its pipeline cases in
VectorEmbeddingIntegrationITare kept).scripts/harness/check_decision_records.pyclean. Collate main and Collate PR getting error while connecting snowflake #8899 both build against this branch(
mvn -B clean install -DskipTests -pl '!collate-ui,!collate-dist').47d2cdf35c8: 1298 unit tests green, 0 failures (108 classes: the packages above plusRecreateWithEmbeddingsTest,OpenMetadataOperations*Testand both bulk sinks). Collate main builds against it. Collate PR getting error while connecting snowflake #8899 builds, andcollate-integration-testscompiles, once it has Collate main's PR #8473: this branch now carries OpenMetadata main's removal ofBackgroundJob.JobType.DELETE_ENTITY, which PR Implement KPI checks in the processing workflow #8473 adapted Collate to.ApplicationFusionIT(OpenSearch 3.4.0 and Elasticsearch9.3.0, 9 cases each): the clause runs inside
function_scoreinsidebool.should, over an aliaswith an index that has no
embeddingfield, with no shard failure; the threshold keeps and dropsthe same documents on both engines; a lowercase
serviceTypefilter matches unnormalized chunks.64740defc33: 1258 unit tests green, 0 failures, 0 errors (99 classes: thesearch.vector,search.queries,search.elasticsearchandsearch.opensearchpackages,SearchRepository*Test,SystemRepository*Test,SystemResource*Test,RecreateWithEmbeddingsTest,OpenMetadataOperations*Test; the 312 OpenSearch tests are unchanged and green). NewElasticsearchVectorMappingUpdateITon Elasticsearch 9.3.0, 4 of 4 green: an index with the pinned options, reached through an alias as after a recreate, gets an upgrade's new field and keepshnsw,m48; an index created with the engine default gets the new field and keeps its default; an index withoutembeddinggets the pinned field when embeddings turn on; a different embedding dimension fails withIllegalStateException. Against the previous head the same IT fails 3 of 4, with Elasticsearch'sCannot update parameter [index_options] from [{type=hnsw, m=48, ef_construction=256}]refusal. Collate main builds against this branch.VectorEmbeddingIntegrationITand the rest of the OpenMetadata IT suite.Checklist:
Fixes <issue-number>: <short explanation>.