Skip to content

Ontology concepts and properties get their own search index with embeddings - #38465

Merged
pmbrull merged 9 commits into
mainfrom
pmbrull/ontology-search-index
Nov 23, 2026
Merged

pmbrull merged 9 commits into
mainfrom
pmbrull/ontology-search-index

Conversation

@pmbrull

@pmbrull pmbrull commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Related to #38419. No issue is linked yet.

Ontology Studio concepts and properties are in no search index, so a term is found only when the question contains its label word.

On a test dataset, a semantic lookup reached the intended term for 2 of 21 phrasings:

  • "clients", "clientes" and "custmer" never reached Customer.
  • "shops" never reached Location.
  • "sales" and "turnover" never reached Revenue before tax.
  • "purchase" never reached Order, although Order's description says "One purchase by a customer".

Glossary terms with the same names are found, because they are indexed with embeddings.

This PR gives ontology terms their own search indexes, with embeddings, outside the data-asset aliases.

Type of change:

  • New feature

High-level design:

Indexes

  • ontology_concept_search_index and ontology_property_search_index, under the shared alias ontologyTerms.
  • Not under all, dataAsset or Data Insights: they are not data assets.
  • Mappings for en, jp, ko, ru and zh.

Documents

  • id, name, FQN, display name and description.
  • Kind, ontology, IRI and synonyms where defined.
  • Domain and range, as IRIs and labels.
  • Owners, including those inherited from the ontology.
  • On concepts, the bound tables, stored as opaque IDs. Admin responses on /search/query, /search/fieldQuery and /nlq/query resolve them to live FQNs. Other callers, and direct index reads, never get binding FQNs.

Which version is indexed

  • Only the active release, through the same publication pointer the RDF serving graph uses.
  • Draft edits, deprecated terms, deleted terms and terms dropped from a new release are removed.

Keeping it current

  • Term documents are written synchronously on create, update, delete and restore.
  • Release activation bulk-writes the deduplicated members of both releases, with one refresh.
  • A change to the ontology's owners refreshes its terms.
  • Binding edits and table deletion or restoration refresh the affected concepts. Table and column names are resolved at query time, without rewriting term documents.
  • Manual /search/reindexEntities uses the published-term writer and preserves matching embedding metadata. Bulk creates send their deduplicated terms to that writer together.
  • With embeddings disabled, missing chunk indexes skip refresh/deletion; existing chunks still receive stale-content cleanup.
  • SearchIndexingApplication reindexes both types. Reads are batched through DocBuildContext.

Embeddings

  • Marked vector-capable the same way as other entity types (fingerprint, AvailableEntityTypes).
  • The embedded text is label, synonyms, description and domain/range labels.
  • Embeddings are written on the asynchronous embedding lane.
  • On OpenSearch the chunks go to a dedicated ontology chunk index, not data_asset_embeddings_chunks. On Elasticsearch the vectors stay in the term indexes.
  • Saved reindex configurations keep sweeping orphaned data-asset chunks.

Decision record: docs/decisions/2026-11-23-ontology-terms-have-dedicated-search-indexes.md.

Rollout: new indexes appear at startup. Existing installs need a reindex of ontologyConcept and ontologyProperty to populate them.

Tests:

Use cases covered

  • A concept is found by label, by a description word ("purchase" finds Order) and by a synonym. Its bound table is listed for an admin.
  • A non-admin never sees a bound table FQN on /search/query, /search/fieldQuery or /nlq/query.
  • A binding change, a table rename and a soft delete update the concept's document.
  • Activating a second release:
    • a term removed from the release disappears;
    • a renamed term keeps its id and shows the new label;
    • a term deprecated in the release disappears.
  • A change to the ontology's owners updates the inherited owners.
  • Deleting a concept removes its document.

Unit tests

  • Reused the unchanged SearchRepositoryTest and SearchResourceTest results from 0ab3cbc2: 32 tests passed, with zero failures, errors, or skips. This follow-up changes only tests.
  • Replaced the mock-only OntologyChunkIndexTest with real OpenSearch integration coverage.

Backend integration tests

  • OntologyTermSearchIT on PostgreSQL/OpenSearch — 8 tests passed, with zero failures, errors, or skips, holding the SEARCH_INDEX_APP lock.
  • With embeddings disabled, live writes remove stale and unpublished chunks while retaining matching and unrelated chunks. A synchronous term write succeeds with no chunk index and leaves it absent; full reindex also removes orphaned chunks.
  • The HTTP manual-reindex regression checks draft exclusion, published definitions, bound asset IDs, domain/range labels, and retained embedding metadata. It waits for the final document write before checking the results.
  • Column edits keep the term document version unchanged while names resolve live. Delete and restore still update indexed bound asset IDs. The suite also covers search access, release activation, stale embeddings, and orphaned chunks.
  • Validation used the focused Maven commands selected by the affected-test planner. Formatting and the normal commit/push hooks passed.
  • Not verified: live embedding-provider calls. Full affected coverage, including the other engine/lane checks and nightly suites, remains pending for merge readiness.

Local Java test run: PASSED

  • Commit: 0ab3cbc2df1d (base refs/review-fixes/20261123/pr-38465-gitar) — uncommitted changes were present
  • Finished: 2026-11-23 14:12 UTC · 4.1 min
  • Scope: focused; merge readiness is not established. Broader steps deferred: 0 (run --scope full).
Step Scope Classes Tests Failed Skipped Min Result
integration postgres-opensearch · search-it 1 8 0 0 4.1 passed

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

  • Confirmed all three review failure paths before the fixes: manual reindex exposed draft text, disabled embeddings still forced a chunk refresh, and column edits rewrote the ontology term document. The corresponding regressions pass after the fixes.

RetriggerView in GreptileConfidence Score: 5/5

The reviewed changes appear safe to merge.

Summary

Adds separate search indexes and embeddings for published ontology concepts and properties.

  • Ontology concepts and properties can be searched through their own indexes.
  • Ontology terms can be searched by embeddings alongside text.
  • Admins can see live bound table names in ontology search results.

No new actionable issues were found in the changes since the previous review. The earlier threads are unnumbered and their reported problems are addressed by the current code. Tests were not run during this review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Release[Active ontology release] --> Writer[Shared term writer]
  Owners[Current owners and binding IDs] --> Writer
  Writer --> Concepts[Concept search index]
  Writer --> Properties[Property search index]
  Writer --> Cleanup[Remove stale chunks]
  Writer --> Lane[Embedding work]
  Lane --> ES[Elasticsearch term vectors]
  Lane --> OS[OpenSearch ontology chunks]
  Concepts --> Search[Search response]
  Properties --> Search
  Search --> Admin[Admin gets live binding names]
  Search --> Reader[Other callers get no binding names]
Loading

Reviews (5) · Last reviewed commit: "test(search): verify ontology chunk clea..." · Reviewed by Greptile

Copilot AI balanced review requested due to automatic review settings November 23, 2026 09:53
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

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.

@pmbrull
pmbrull requested a review from a team as a code owner November 23, 2026 09:54
@pmbrull
pmbrull requested a review from IceS2 November 23, 2026 09:55
Use the ontology fields in lexical queries and serialize term writes across live refreshes and reindex jobs. Remove OpenSearch chunks when their parent or publication fingerprint is stale.
Copilot AI balanced review requested due to automatic review settings November 23, 2026 11:06

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 11:27

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.

Route manual ontology reindexing through the release-aware writer to
keep drafts out of search and retain embedding metadata.

Batch bulk term creates, skip refreshes for absent chunk indexes, and
resolve binding names at read time. Retain delete and restore refreshes
for bound asset IDs and cleanup of existing stale chunks.
Copilot AI balanced review requested due to automatic review settings November 23, 2026 13: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.

Replace mock call counts with real OpenSearch assertions for live writes
with embeddings disabled, retained matching chunks, and absent chunk indexes.
Copilot AI balanced review requested due to automatic review settings November 23, 2026 14:13

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 23, 2026 •

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

Ontology search resolves bound asset IDs to table and column FQNs only for admins, changing an access-control boundary; a leak could expose restricted metadata.

Adds dedicated ontology concept and property search indexes with embeddings, kept in sync with active releases, term changes, and binding edits, with bound table FQNs shown only to admins. Two resolved items: the postDelete profiler-purge Javadoc now documents postUpdate, and the chunk-index test no longer relies only on verify() mock wiring. No open issues remain.

✅ 2 closed
✅ Quality: postDelete's profiler-purge Javadoc now documents postUpdate

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TableRepository.java:1858-1870 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TableRepository.java:1889-1892
The new postUpdate, postRestore and helper methods were inserted between the existing Javadoc and postDelete. That Javadoc explains why the profiler purge runs after commit and how it is bounded, but it now sits on postUpdate, which has nothing to do with profiler purging. postDelete is left with no documentation. Anyone reading either method, or the generated docs, gets the wrong explanation. Move the new methods above the Javadoc block, or move the block back down so it sits directly over postDelete.

✅ Quality: New chunk-index test only checks mock wiring with verify() calls

📄 openmetadata-service/src/test/java/org/openmetadata/service/search/OntologyChunkIndexTest.java:28-42
OntologyChunkIndexTest mocks two of the project's own classes (SearchRepository, OpenSearchClient), stubs the OpenSearch backend, and asserts nothing except verify(..., times(n)) on refresh and deleteByQuery. The repo's testing rules forbid this: assert observable outcomes, not call choreography. Here the test would still pass if deleteStaleChunks built the wrong query or targeted the wrong index, as long as the call count matched. A better test seeds stale chunks in a real OpenSearch with embeddings disabled, as reindexSweepsStaleInactiveAndMissingOntologyChunks already does with seedChunk/chunkCount, then asserts the chunks are removed. Another option is a second case that writes a term when the chunk index is absent and asserts the write succeeds and the index is not created.

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

@pmbrull
pmbrull merged commit 2cb0f81 into main Nov 23, 2026
62 of 65 checks passed
@pmbrull
pmbrull deleted the pmbrull/ontology-search-index branch November 23, 2026 14:51
harshach added a commit that referenced this pull request Nov 24, 2026
#36491 removed it as unused, but #38465 had already added callers in the
Elasticsearch and OpenSearch bulk sinks, so main no longer compiles.
harshach added a commit that referenced this pull request Nov 24, 2026
…ice unit tests (#38626)

* Fixes #38613: Restore StageStatsTracker.recordProcessBatch

#36491 removed it as unused, but #38465 had already added callers in the
Elasticsearch and OpenSearch bulk sinks, so main no longer compiles.

* Share one database server per dialect in OntologyTestDatabase

Each withDatabase call started a new MySQL or PostgreSQL container. Start one
per dialect per JVM and give each call its own empty database instead, which
keeps the isolation of a fresh container.

* Run openmetadata-service unit tests in parallel forks

Surefire ran every class serially in one JVM. Fork one JVM per CPU and reuse
the forks; each keeps its own static registries and test containers.
Decision: ADR:2026-11-24-service-unit-tests-run-in-parallel-forks

* Add ScratchDatabase: an empty database on the IT suite's server

SQL and migration tests that build their own schema get a database on the
lane's MySQL or PostgreSQL container instead of starting their own.

* Move group B SQL and migration-step tests into the IT module

The 22 classes run on ScratchDatabase (an empty database on the lane's server)
instead of starting their own MySQL/Postgres containers. Per-dialect pairs keep
both methods and skip the other dialect; dialect-parameterized tests run the
lane's dialect only. Per-method scratch databases for the migration tests come
from ScratchDatabasePerTest.

* Move search, Redis, LocalStack and session-store container tests into the IT module

Thirteen Docker-backed service tests (plus their abstract bases) now run on the IT suite's
infrastructure: the lane's search engine and Redis, S3Proxy for S3, and new on-demand helpers in
TestSuiteBootstrap for LocalStack (S3, Secrets Manager, SSM), dedicated Redis servers (cluster mode,
pausable) and a dedicated OpenSearch for fixtures that occupy names the application owns. Adds
mockito-core as an IT test dependency.

* Move ontology storage tests into the integration-test module

The 21 ontology storage, MCP SQL and tag-usage tests, with OntologyTestDatabase and
OntologyCaptureFixture, now run as *IT classes against ScratchDatabase on the lane's
MySQL or PostgreSQL server instead of starting their own container. Dialect-parameterized
tests became plain tests on ScratchDatabase.dialect(); the Fixture-based classes that swap
the static Entity registry are @isolated and restore the registry through
EntityRegistrySnapshot. mockito-core is added as a test dependency of the module.

* Keep container tests out of the service unit suite

openmetadata-service drops its Testcontainers test dependencies, so a test
that needs a real database, search engine, Redis or AWS service has to be an
IT. The IT pom registers the moved @isolated classes in the global-state
lane and keeps surefire off *IT classes that live in service packages. The
impact map owns the moved ITs, and the decision record now says unit tests
are mock-only.
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.

3 participants