Repository navigation
Conversation
…asticsearch AIContextFinder and CompanyContextTool read OpenSearchVectorService.getInstance(), which is only initialised when searchType is OpenSearch. On Elasticsearch it is always null, so find_context silently returned an empty result and company_context reported "Semantic search is not enabled" even with embeddings present. Read the backend-neutral SearchRepository.getVectorIndexService() instead, as SemanticSearchTool already does. On OpenSearch it returns the same OpenSearchVectorService instance as before.
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
|
Local Java test run: FAILED — details
Selected but produced no report: Tests run locally
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. integration · mysql-elasticsearch · parallel: 45 classes
Why these tests
Commandsmvn -B package -pl openmetadata-mcp,openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=AIContextFinderTest,CompanyContextToolTest,ConceptContextCatalogTest -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel '-Dit.test=<45 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=ContextMemoryDerivationIT,ContextMemoryExtractionIT,ConversationSchemaMigrationIT -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,RdfMcpKnowledgeGraphIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false |
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
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 |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change to use the configured backend-neutral vector service.
No open issues 🎉
What changed in this PR
Fixes #36463 by routing find_context and company_context through the configured backend-neutral vector service, enabling Elasticsearch searches while preserving the existing OpenSearch behavior.
Changes:
- Replaces OpenSearch singleton lookups with
SearchRepository.getVectorIndexService()in both search paths. - Adds finder regression coverage, updates company-context tests to use
VectorIndexService, and covers an unavailable vector service.
| File | Description |
|---|---|
openmetadata-service/src/test/java/org/openmetadata/service/aicontext/AIContextFinderTest.java |
Tests returned knowledge when the OpenSearch singleton is null. |
openmetadata-service/src/main/java/org/openmetadata/service/aicontext/AIContextFinder.java |
Resolves the configured vector service for knowledge searches. |
openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/CompanyContextToolTest.java |
Updates service mocks and tests the unavailable-service response. |
openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/CompanyContextTool.java |
Uses the backend-neutral service for company-context searches. |
Review effort: Balanced
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
Code Review ✅ Approved🟡 Medium risk · Switching context tools to the backend-neutral vector service enables Elasticsearch retrieval, which could surface unexpected semantic matches in AI context results. Switches 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 |
Backport #36548 to 2.0. (cherry picked from commit 961fb5f) Co-authored-by: Mostafa Abdelsalam <[email protected]>
…asticsearch (open-metadata#36548) AIContextFinder and CompanyContextTool read OpenSearchVectorService.getInstance(), which is only initialised when searchType is OpenSearch. On Elasticsearch it is always null, so find_context silently returned an empty result and company_context reported "Semantic search is not enabled" even with embeddings present. Read the backend-neutral SearchRepository.getVectorIndexService() instead, as SemanticSearchTool already does. On OpenSearch it returns the same OpenSearchVectorService instance as before. Co-authored-by: Pere Miquel Brull <[email protected]> (cherry picked from commit 961fb5f) Backport to 2.0.7: import-only conflict in AIContextFinder (2.0.7 has no MetricRepository import); AIContextFinderTest keeps the 2.0.7 tests and adds only the test this commit introduced.
Describe your changes:
Fixes #36463
find_contextandcompany_contextreturned nothing on Elasticsearch even with semantic search enabled and embeddings present.AIContextFinderandCompanyContextToolreadOpenSearchVectorService.getInstance(), a singleton thatSearchRepository.initializeVectorSearchService()only creates whensearchTypeis OpenSearch. On Elasticsearch it is always null, so the finder skipped its search silently ({"items":[],"candidateAssets":[],"empty":true}) andcompany_contextanswered "Semantic search is not enabled".Both now read
Entity.getSearchRepository().getVectorIndexService(), the accessorSemanticSearchToolandVectorSearchResourcealready use. On OpenSearch it returns the sameOpenSearchVectorServiceinstance as before, so nothing changes there. Both call sites only usesearch(...)overloads declared onVectorIndexService, andElasticSearchVectorServiceapplies the same memory-visibility filter (readableAnchors,appendMemoryVisibilityFilter), so the per-user filter incompany_contextstill applies on Elasticsearch.Same fix as #32547, which its author closed before review after the PR metadata check failed.
Overlap with #36517: that PR (opened earlier today) contains the identical five-line change in the same four files. I prepared this independently as the reporter of #36463 and am opening it because it carries extra verification (a real Elasticsearch before/after run and the planner-selected integration tests, below). I'm happy to close this in favour of #36517 if the maintainers prefer, and to move any of the evidence onto it.
Type of change:
High-level design:
N/A, small change: 5 changed lines in 2 files.
Out of scope, not changed here:
GetEntityToolandAIContextBuildercallsearchChunksByParent, which exists only onOpenSearchVectorService(Elasticsearch has no chunk index), so they fall back to the full text on Elasticsearch. The remainingOpenSearchVectorService.getInstance()callers are index-write paths (OpenSearchBulkSink,DistributedJobParticipant,RecreateWithEmbeddings,VectorSearchUtils).Tests:
Use cases covered
find_context/GET /api/v1/ai/context/findreturns matching glossary terms, metrics and pages on Elasticsearch.company_contextwith aqueryruns its vector query on Elasticsearch instead of reporting "Semantic search is not enabled".company_contextstill reports "Semantic search is not enabled".Unit tests
AIContextFinderTest(new:find_usesTheBackendNeutralVectorServiceWhenTheOpenSearchSingletonIsNull, with the OpenSearch singleton null and the neutral service returning one hit),CompanyContextToolTest(3 existing tests now injectVectorIndexServicethroughSearchRepository; newsearchReportsSemanticSearchNotEnabledWhenNoVectorServiceWasCreated).AIContextFinderTest.find_usesTheBackendNeutralVectorService...fails withexpected: <[Business.BounceRate]> but was: <[]>, and 3 of theCompanyContextToolTesttests fail. Green after.-Pstatic-code-analysis,AIContextFinderTest,CompanyContextToolTest,AIContextFinderAccessTest): every changed executable line is covered. Whole-class line coverage is 83.7% forAIContextFinder(118/141) and 89.1% forCompanyContextTool(106/119), below the 90% target; the uncovered lines are existing code this PR does not touch (candidate-asset routing and the othercompany_contextpaths).searchReports...NotEnabled...test is a regression guard for the null branch; its assertion alone also passes on the old code, and it fails on a revert only through Mockito strict stubs.Backend integration tests
openmetadata-integration-tests/for new/changed API endpoints.find_contextis left as a follow-up.make java_affected_runselected 3 unit classes and 50 integration classes (45 in the parallel lane, 3 isolated, 2 rdf). 2,024 tests ran and passed (35 unit, 1,934 + 12 + 43 integration), 147 skipped themselves, and none failed. Theparallelstep is marked FAILED only becauseMcpServiceResourceITis selected but cannot produce a report: the file is aTODOcomment with no class or tests, and it is identical onorigin/main. The "uncommitted changes" note in the block below refers to two unrelated local files that are not in this PR's commit.Local Java test run: FAILED
f7a8a71ba3c9(baseorigin/main) — uncommitted changes were presentSelected but produced no report:
McpServiceResourceIT (mysql-elasticsearch · parallel)Ingestion integration tests
Playwright (UI) tests
Manual testing performed
Built a server image from
main(a9757cf0), then from this branch, and ran each against Elasticsearch 9.4.2 and Postgres in Docker.mvn -DskipTests -Dskip.ui.build=true -pl openmetadata-dist -am packageanddocker build -f docker/development/Dockerfile.SEARCH_TYPE=elasticsearch SEMANTIC_SEARCH_ENABLED=true LLM_ENABLED=true LLM_PROVIDER=openai EMBEDDING_PROVIDER=openai(text-embedding-3-small). The log showsElasticSearchVectorService initializedand no OpenSearch service.embedding.mainGET /api/v1/ai/context/find?q=bounce rate{"items":[],"candidateAssets":[],"empty":true}GET /api/v1/ai/context/find?q=qualified visitsfind_context"bounce rate"# Relevant Knowledge, Bounce Rate firstcompany_contextwithquery{"returnedCount":0,"results":[]}(no pills exist)semantic_search(control)UI screen recording:
Not applicable, backend-only change.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.REVIEW.mdand fixed every 🔴 finding, or answered it on the line below.f7a8a71ba3c9ceca1c1a872049f9378fc79c78d8with a fresh reviewer: no 🔴 findings. Left as 🟡 notes: no real-engine IT (follow-up), the finder still turns a failed search into an empty result (pre-existing), and the new null-branch test is a weak guard (disclosed above).docs/decisions/.Bug fix