Repository navigation
Fixes #35640: Clamp num_candidates to Elasticsearch engine maximum of 10000 - #35652
Conversation
|
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! |
✅ Generated Sources Auto-UpdatedThe generated TypeScript types ( |
🔄 Playwright impact map auto-refreshedThis PR touched specs or UI source that changed the source→spec routing map. I regenerated What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit: python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit # or a separate commit |
c82ed8e to
914e240
Compare
🚦 Removed from the merge queue —
|
🚦 Removed from the merge queue —
|
…tes-to-elasticsearch-4e5a21
|
|
🚦 Removed from the merge queue —
|
… 10,000 Backport of upstream open-metadata#35652 (fixes open-metadata#35640) to 2.0.7. num_candidates was max(100, k * knnNumCandidatesMultiplier) with no upper bound, so any k above 10,000 / multiplier made Elasticsearch reject the kNN query and the vector search endpoint and the MCP semantic_search tool return 500. With a multiplier of 50 that is any k above 200, including the REST endpoint's default k of 1,000. Only the query builder and its tests are backported; the upstream schema description and generated UI types are unchanged here. Co-Authored-By: Claude Opus 5.5 <[email protected]>



Detail bug report: View on Detail
Describe your changes:
Fixes #35640
I clamped
num_candidatesto Elasticsearch's engine maximum of 10,000 inVectorSearchQueryBuilder.buildNativeESQuery, because the query builder previously computednum_candidates = k × multiplierwith only anInteger.MAX_VALUEoverflow guard. With the defaultknnNumCandidatesMultiplierof 2, anyk > 5,000— including the API's own advertisedMAX_K = 10,000— producednum_candidates > 10,000, which Elasticsearch hard-rejects with a 400. The service converted that 400 into an opaque HTTP 500 ({"error":"An internal error occurred"}), so every vector search withkin(5000, 10000]silently failed on Elasticsearch deployments.Type of change:
High-level design:
N/A — small change.
Tests:
Use cases covered
k = 10,000(the REST API and MCPSemanticSearchTooladvertised maximum) produces a valid Elasticsearch request instead of a 400/500kin[1, 10,000]and any configured multiplier never exceeds the engine's 10,000num_candidatescapk × multiplier ≤ 10,000) are unchanged — no regressionUnit tests
openmetadata-service/src/test/java/org/openmetadata/service/search/vector/VectorSearchQueryBuilderTest.java— updated the existing overflow-clamp test to assert the 10,000 engine cap (wasInteger.MAX_VALUE); added tests for the advertisedMAX_K = 10,000scenario, high-multiplier clamping, and a property-based sweep overk(1..10,000) × multipliers {1,2,3,5,10,50,100}openmetadata-service/src/test/java/org/openmetadata/service/search/vector/ElasticSearchVectorServiceTest.java— added a test verifying the clamp reaches the actual HTTP request body through the fullsearch()pathwayVectorSearchQueryBuilder(JaCoCo,mvn test -P static-code-analysis)Backend integration tests
VectorEmbeddingIntegrationIT(10 tests, OpenSearch 3.4.0 via Testcontainers) ran successfully with no regressions.Ingestion integration tests
Playwright (UI) tests
Manual testing performed
TestSuiteBootstrap(MySQL 8.3.0 + Elasticsearch 9.3.0 + OpenMetadata app) to exercisePOST /v1/search/vector/queryend-to-end, but the bootstrap fails with a pre-existingAppScheduler is not Initializederror duringOpenMetadataApplication.registerResources()— unrelated to this fix, which only touches the query builder'snum_candidatesclamp and the config schema description.UI screen recording:
Not applicable — backend-only change.
Checklist:
Fixes #35640: Clamp num_candidates to Elasticsearch engine maximum of 10000Fixes #35640above.knnNumCandidatesMultiplierdescription text was updated, no schema field or type changed.Automatic Fixes PRs can be configured here.


Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
Caps Elasticsearch
num_candidatesat 10,000 while keeping the existing minimum of 100 and overflow-safe multiplication.Reviews (4) · Last reviewed commit: "Merge branch 'main' into detail/bug-fix/..." · Reviewed by Greptile