Repository navigation
Fixes #36463: use the configured vector service for find_context and company_context on Elasticsearch - #36517
zerafachris wants to merge 2 commits into
Conversation
…_context and company_context on Elasticsearch AIContextFinder and CompanyContextTool read the OpenSearchVectorService singleton, which is only created when the search backend is OpenSearch. Read the backend-neutral VectorIndexService held by SearchRepository instead.
❌ 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 |
|
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! |
|
@pmbrull @Vishnuujain Ready for review and |
|
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 · Using the configured vector service restores Elasticsearch results for find_context and company_context; inaccurate matches could add irrelevant material to responses. 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 |
|
hi thank you, closing in favor of #36548 since it's same approach 🙏 |
Describe your changes:
Fixes #36463
Root cause:
SearchRepository.initializeVectorSearchService()createsOpenSearchVectorServiceonly when the search backend is OpenSearch. On Elasticsearch it createsElasticSearchVectorServiceand stores it inSearchRepository.vectorIndexService, soOpenSearchVectorService.getInstance()staysnull.AIContextFinder.searchKnowledge()andCompanyContextTool.runSearch()both read that OpenSearch-only singleton. As a resultfind_context/GET /api/v1/ai/context/findsilently returned nothing, andcompany_contextreported "Semantic search is not enabled", even thoughsemantic_searchworks on the same index.What changed: both call sites now use
Entity.getSearchRepository().getVectorIndexService(), the backend-neutralVectorIndexServicealready used by the rest of the vector pipeline. This is the change the reporter proposed in the issue (thanks @MostafaAbdelsalam11). The methods they call (search(...), including theSubjectContextoverload) are on the interface, andElasticSearchVectorServiceapplies the same context-memory visibility filtering (readableAnchorIds) as the OpenSearch implementation.Scope: only the two call sites named in the issue.
AIContextBuilder.queryRelevantExcerptstill reads the OpenSearch singleton becausesearchChunksByParentis not onVectorIndexServiceand has no Elasticsearch implementation, so excerpts stay absent on Elasticsearch exactly as before (no regression). The remaininggetInstance()callers (VectorSearchUtils,RecreateWithEmbeddings,OpenMetadataOperations,OpenSearchBulkSink,DistributedJobParticipant) are OpenSearch-specific paths and are out of scope here.Tests:
AIContextFinderTest.findSearchesTheConfiguredVectorServiceOnElasticsearch: fails on main (the vector service is never queried) and passes with the fix.AIContextFinderTest: 10/10.CompanyContextToolTest.searchRunsOnTheElasticsearchVectorService: fails on main (the "not enabled" error is returned) and passes with the fix.CompanyContextToolTest: 18/18.CompanyContextToolTestsearch tests stubbedOpenSearchVectorService.getInstance()statically. They now stubsearchRepository.getVectorIndexService()instead. Assertions are unchanged.mvn spotless:checkpasses foropenmetadata-serviceandopenmetadata-mcp.Prepared with AI assistance (Claude Code, Anthropic), reviewed for correctness before submission.
Type of change:
Checklist:
Fixes <issue-number>: <short explanation>