fix(search): apply minimum_should_match floor to column index search - #31019
fix(search): apply minimum_should_match floor to column index search#31019mohityadav766 wants to merge 1 commit into
Conversation
Column search (index=tableColumn) routes through buildColumnSearchBuilderV2,
which passed "0" as the multi_match fuzziness argument. minimum_should_match
was only ever set inside the `!fuzziness.equals("0")` branch, so the "0"
sentinel silently dropped the floor -- leaving a bare OR multi_match that
matched any column sharing a single token (e.g. a common parent-name token in
fullyQualifiedName / table.name). A specific-FQN search therefore returned the
whole column index while the dataAsset aggregation counted only the true
matches, so the Explore "Columns" tab count and the results diverged
(e.g. count 1 vs 7,381 results).
Pass the existing MINIMUM_SHOULD_MATCH ("2<70%") constant to the multi_match in
both the OpenSearch and Elasticsearch source-builder factories, and add a
regression test asserting the serialized column query carries the floor.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
❌ 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 |
Code Review ✅ ApprovedApplies the MINIMUM_SHOULD_MATCH floor constant to column index search queries in both OpenSearch and Elasticsearch factories to fix result count divergence. No issues found. OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar | Powered by Gitar — free for open source |
There was a problem hiding this comment.
Pull request overview
This PR fixes an overly-permissive column-index search query by ensuring minimum_should_match is applied even when fuzziness is the "0" sentinel, preventing FQN-style column searches from matching the entire column_search_index and eliminating the mismatch between aggregation counts and returned results.
Changes:
- Apply
MINIMUM_SHOULD_MATCH("2<70%") to the column-indexmulti_matchquery in both OpenSearch and Elasticsearch builder factories via the overload that setsminimum_should_matchunconditionally. - Add a regression unit test asserting that both factories’ serialized queries include
"minimum_should_match":"2<70%".
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchSourceBuilderFactory.java | Ensure column-index multi_match applies MINIMUM_SHOULD_MATCH even with fuzziness "0". |
| openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchSourceBuilderFactory.java | Mirror the same column-index minimum_should_match behavior for Elasticsearch. |
| openmetadata-service/src/test/java/org/openmetadata/service/search/SearchSourceBuilderFactoryTest.java | Add regression coverage verifying the minimum_should_match floor is present for both backends. |
🔴 Playwright Results — workflow failedValidated commit ✅ 1023 passed · ❌ 1 failed · 🟡 2 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky Pipeline and setup failures (1)
PerformanceBlocking targets: ❌ unmet · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 59m 56s ⏱️ Max setup 3m 11s · max shard execution 19m 17s · max shard-job elapsed before upload 30m 32s · reporting 7s 🌐 189.69 requests/attempt · 2.21 app boots/UI scenario · 13.74% common-shard skew Optimization targets still in progress:
Genuine Failures (failed on all attempts)❌
|
Describe your changes:
Fixes open-metadata/openmetadata-collate#3851
Column search (
index=tableColumn) routes throughbuildColumnSearchBuilderV2, which passed"0"as themulti_matchfuzziness argument.minimum_should_matchwas only ever applied inside the!fuzziness.equals("0")branch, so the"0"sentinel silently dropped the floor — leaving a barebest_fields/ORmulti_matchthat matches any column sharing a single token (e.g. a common parent-name token infullyQualifiedName/table.name).As a result, a specific-FQN column search returned the entire column index, while the
dataAssetaggregation (strict builder,minimum_should_match(1)) counted only the true matches — so the Explore Columns tab count and the results list diverged (observed: tab count 1, results 7,381).Fix: pass the existing
MINIMUM_SHOULD_MATCH("2<70%") constant to themulti_matchin both the OpenSearch and Elasticsearch source-builder factories. The 9-arg overload appliesminimum_should_matchunconditionally (independent of fuzziness). Exact-name searches (1–2 tokens) still match; long FQN-style queries now require ~70% token overlap instead of a single shared token.Changed:
openmetadata-service/.../search/opensearch/OpenSearchSourceBuilderFactory.java—buildColumnSearchBuilderV2openmetadata-service/.../search/elasticsearch/ElasticSearchSourceBuilderFactory.java—buildColumnSearchBuilderV2Type of change:
Tests:
Unit tests
SearchSourceBuilderFactoryTest.testColumnIndexSearchAppliesMinimumShouldMatchFloor— builds the column query for both OpenSearch and Elasticsearch and asserts the serialized query carries"minimum_should_match":"2<70%". Fails on the previous code (floor absent), passes with the fix.SearchSourceBuilderFactoryTest: 18/18 pass locally.Backend integration tests
ColumnSearchIndexITasserts a column is findable by name, which this change preserves — and makes more robust, since the target column is no longer buried beyondsize(10)among thousands of permissive matches.UI screen recording / screenshots:
Not applicable (backend search-query change).
Checklist:
🤖 Generated with Claude Code