Skip to content

Fixes #38569: keep draft ontology terms out of reembed semantic search writes - #38574

Merged
harshach merged 1 commit into
mainfrom
detail/bug-fix/fixes-38569-keep-draft-ontology-terms-out-of-reemb-41235e
Nov 25, 2026
Merged

harshach merged 1 commit into
mainfrom
detail/bug-fix/fixes-38569-keep-draft-ontology-terms-out-of-reemb-41235e

Conversation

@detail-app

@detail-app detail-app Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Detail bug report: View on Detail

Describe your changes:

Fixes #38569

I worked on keeping draft/unpublished ontology terms out of the semantic-search chunk index when the reembed CLI runs, because the 2-arg updateEntityEmbeddings overload keyed its term vs. data-asset branch on whether an ontologyBody was passed rather than on the entity type. The reembed CLI iterates all of AvailableEntityTypes.LIST (which includes ontologyConcept/ontologyProperty) using that 2-arg overload, so it embedded every term from its mutable working (draft) DB row straight into the searchable ontology_embeddings_chunks index with no publication check — publishing drafts, terms of a sealed-but-unactivated release, and terms deprecated in the active release. Every other term entry point routes through the release-aware gated writer (OntologyTermSearch.writeCurrentEmbedding), which only writes active, non-deleted, non-deprecated members of the published release, using content from the release snapshot (ADR 2026-11-23-ontology-terms-have-dedicated-search-indexes).

Type of change:

  • Bug fix

High-level design:

N/A — small change.

Two-layer fix:

  • Vector services (OpenSearchVectorService, ElasticSearchVectorService): updateEntityEmbeddings(entity, indexName, ontologyBody) now selects the term path by entity type, not by ontologyBody == null. When OntologyTermSearch.isTerm(type) and no body is supplied, it warns and returns before building chunk docs — so no embedding provider call is made and nothing is written. Terms with a body still route through writeCurrentOntologyEmbeddings / writeCurrentEmbedding (the release-aware gate). Non-term entities are unchanged.
  • reembed CLI (OpenMetadataOperations): the producer loop and calculateReembedTotalBatches now skip ontology term types via a small static isReembedableEntityType predicate (mirrors the existing planSmartReindex/resolveChangedEntities helper pattern). Term embeddings are rebuilt only via the release-aware reindex path, as the ADR prescribes for manual reindexing.

The two layers are belt-and-braces: the CLI skips terms, and the vector-service guard refuses them even if a term reaches the 2-arg path through some future caller.

Tests:

Use cases covered

  • reembed CLI no longer embeds/publishes draft, sealed-but-unactivated, or deprecated-in-active-release ontology terms into the searchable chunk index.
  • Non-term data-asset entities (tables, charts, glossary terms, context memories, …) are still re-embedded by reembed exactly as before.
  • Ontology term embeddings are still rebuilt only via the release-aware reindex path (active, non-deprecated, non-deleted members of the published release).

Unit tests

  • I added unit tests for the new/changed logic.
  • Files added/updated:
    • openmetadata-service/.../search/vector/OpenSearchVectorServiceTest.java — twoArgOverloadRefusesOntologyConceptWithoutWritingOrEmbedding, twoArgOverloadRefusesOntologyPropertyWithoutWritingOrEmbedding, twoArgOverloadStillWritesNonTermEntities
    • openmetadata-service/.../search/vector/ElasticSearchVectorServiceTest.java — twoArgOverloadRefusesOntologyConceptWithoutWritingOrEmbedding
    • openmetadata-service/.../util/OpenMetadataOperationsReembedEligibilityTest.java (new) — pins isReembedableEntityType excluding both term kinds and keeping data-asset types re-embeddable.

The vector-service tests assert no OpenSearch/Elasticsearch requests and no embedding provider calls are issued for a term on the 2-arg path, and that a Table still writes its chunks. The eligibility test pins the CLI's term-type skip.

Backend integration tests

  • Not applicable (no backend API changes). The authoritative end-to-end guard for the release-aware path is OntologyTermSearchIT (search-it, nightly), which exercises activate → only active terms surface, drafts don't, deprecated terms are excluded, and the reindex path repopulates from the release snapshot. It is unchanged by this fix.

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

Ran the java-affected-tests impacted plan (make java_affected after git fetch origin main), which selected both vector services (both engines, per the OpenSearch*/Elastic* engine rules) and the OpenMetadataOperations area. Ran its exact unit command for the impacted set: 458 tests across openmetadata-service + openmetadata-mcp (including OpenSearchVectorServiceTest 37, ElasticSearchVectorServiceTest 25, SearchRepositoryBehaviorTest 159, both bulk-sink behavior tests, DistributedJobParticipantTest, SemanticSearchToolTest, GetEntityToolTest, VectorEmbeddingHandlerTest, AvailableEntityTypesConsistencyTest, OntologyTermIndexTest), 0 failures, 0 errors. Spotless apply + check clean; targeted compile of openmetadata-service clean.

I could not run the integration tests (OntologyTermSearchIT and VectorEmbeddingIntegrationIT) in this environment: TestSuiteBootstrap throws TestSuiteBootstrap initialization failed during app startup — an NPE in the v200.MigrationUtil task-workflow seed (Entity.getEntityRelationshipRepository() returns null) that fires before any test class loads. I confirmed this is pre-existing and not caused by this change by stashing my changes and re-running the exact IT command against the unmodified baseline, which produced the identical failure (0 tests run, BUILD FAILURE). The same blocker reproduces on both the search-it and global-state lanes because TestSuiteBootstrap is a shared LauncherSessionListener. No running OpenMetadata server was obtainable to manually run the reembed CLI end-to-end for the same reason.

UI screen recording:

Not applicable — backend-only search/vector change, 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.
  • 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).
  • 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.
  • Decision check: this change enforces an existing decision (ADR 2026-11-23-ontology-terms-have-dedicated-search-indexes: "Manual entity reindexing uses the same published-term writer") rather than introducing a new one, so no new docs/decisions/ record is required.

Automatic Fixes PRs can be configured here.

@detail-app
detail-app Bot requested a review from a team as a code owner November 24, 2026 09:21
@detail-app
detail-app Bot requested review from TeddyCr and pmbrull November 24, 2026 09:21
@harshach
harshach merged commit e0e5fd7 into main Nov 25, 2026
49 checks passed
@harshach
harshach deleted the detail/bug-fix/fixes-38569-keep-draft-ontology-terms-out-of-reemb-41235e branch November 25, 2026 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Detail Bug] Search: reembed publishes draft/unreleased ontology terms into semantic search index

2 participants