Repository navigation
fix(search): route column search through structured builder (fqnParts + AND) - #31106
Conversation
…unts match results index=tableColumn (the Explore Columns tab) went through buildColumnSearchBuilderV2, a permissive multi_match (best_fields, operator OR) that omitted fqnParts. An FQN query therefore OR-matched every column sharing a parent-name token and returned the whole column index (e.g. 7381), while the dataAsset aggregation that backs the tab count uses the structured builder (operator AND over fqnParts) and correctly returns 1. Route column indexes through buildDataAssetSearchBuilderV2 so they use the existing "tableColumn" AssetTypeConfiguration (fqnParts + AND): an FQN search now matches the one column precisely (count == results) and column-name search still works via the config's name/name.ngram fields. Removes the now-unused buildColumnSearchBuilderV2 from both engine factories. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
❌ 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.
Pull request overview
This PR fixes an Explore Columns tab inconsistency where index=tableColumn searches could return thousands of loosely token-matching columns while the tab count (driven by the structured dataAsset aggregation) correctly reported a single match. It does so by routing column-index searches through the existing structured buildDataAssetSearchBuilderV2 path so tableColumn uses its AssetTypeConfiguration (including fqnParts with AND semantics), and it adds unit + integration coverage to prevent regressions.
Changes:
- Route
isColumnIndex(indexName)searches throughbuildDataAssetSearchBuilderV2(...)for both OpenSearch and Elasticsearch factories. - Remove the now-unused permissive
buildColumnSearchBuilderV2implementations (and relatedColumnSearchIndeximports). - Add unit and integration tests verifying
tableColumnqueries includefqnParts+"operator":"and"and that FQN searches return exactly 1 hit.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchSourceBuilderFactory.java | Route column-index queries through the structured data-asset builder; remove old column-specific builder. |
| openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchSourceBuilderFactory.java | Same routing/removal as OpenSearch for Elasticsearch queries. |
| openmetadata-service/src/test/java/org/openmetadata/service/search/SearchSourceBuilderFactoryTest.java | Add unit test asserting tableColumn builder emits fqnParts and AND operator (both engines). |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/ColumnSearchIndexIT.java | Add OpenSearch integration test ensuring full column FQN search is precise (total == 1 and correct hit). |
✅ Playwright Results — workflow succeededValidated commit ✅ 1026 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · 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) 57m 24s ⏱️ Max setup 3m 6s · max shard execution 17m 2s · max shard-job elapsed before upload 21m 40s · reporting 6s 🌐 189.14 requests/attempt · 2.21 app boots/UI scenario · 16.83% common-shard skew Optimization targets still in progress:
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
Code Review ✅ ApprovedRoutes column search queries through the structured builder with fqnParts and AND logic, aligning the result list with aggregations and fixing search count mismatches. 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 |
…unts match results (#31106) (#31207) index=tableColumn (the Explore Columns tab) went through buildColumnSearchBuilderV2, a permissive multi_match (best_fields, operator OR) that omitted fqnParts. An FQN query therefore OR-matched every column sharing a parent-name token and returned the whole column index (e.g. 7381), while the dataAsset aggregation that backs the tab count uses the structured builder (operator AND over fqnParts) and correctly returns 1. Route column indexes through buildDataAssetSearchBuilderV2 so they use the existing "tableColumn" AssetTypeConfiguration (fqnParts + AND): an FQN search now matches the one column precisely (count == results) and column-name search still works via the config's name/name.ngram fields. Removes the now-unused buildColumnSearchBuilderV2 from both engine factories. Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
…unts match results (#31106) (#31208) index=tableColumn (the Explore Columns tab) went through buildColumnSearchBuilderV2, a permissive multi_match (best_fields, operator OR) that omitted fqnParts. An FQN query therefore OR-matched every column sharing a parent-name token and returned the whole column index (e.g. 7381), while the dataAsset aggregation that backs the tab count uses the structured builder (operator AND over fqnParts) and correctly returns 1. Route column indexes through buildDataAssetSearchBuilderV2 so they use the existing "tableColumn" AssetTypeConfiguration (fqnParts + AND): an FQN search now matches the one column precisely (count == results) and column-name search still works via the config's name/name.ngram fields. Removes the now-unused buildColumnSearchBuilderV2 from both engine factories. (cherry picked from commit f6d0eb4) Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
…le hit testColumnFqnSearchIsPrecise asserted that searching a column's full FQN returns exactly one hit. The tableColumn ranking configuration cannot deliver that: its stages are should-clauses with minimum_should_match "2<70%" over name/fqnParts/table.name, and a sibling column in the same table shares every FQN token except its own name, so it clears 70% and matches by construction. The CI response showed 8 hits - the 3 columns of the table under test plus the user_id column of 5 sibling tests, all matching the structuralContext stage. The assertion also could not be reached by the path it described: a plain FQN has no query syntax, so containsQuerySyntax is false and the query never takes the operator-AND branch the comment referred to; it goes through the ranked simple-query path instead. Assert the property the fix in #31106 actually restored - the count backing the Explore Columns tab agrees with the results beneath it, and the exact FQN ranks first - and keep a bound that still catches the original fan-out (that bug returned 7381 hits for one FQN). Verified by replaying all three assertions against the recorded failing response. Making an exact-FQN column query isolating would be a change to the search relevance settings rather than to this test. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The recall-widening this PR set out to fix is real, but the gate was in the
wrong place. isFuzzyStageUseful dropped the entire fuzzyName stage whenever
fuzziness was off and the query was one whitespace term. getFuzziness()
disables fuzziness past 2 sub-tokens, so that covers essentially every
identifier-shaped query - and the stage is the only source of partial-token
recall for a name. Its own lane caught the cost:
SearchResourceIT:525 medium prefix (autocomplete mid-type)
[query="xqz77bfa_lhr__i"]: expected shouldFind=true but got found=false
SearchResourceIT:525 one-char typo inside a segment
[query="...__incaming_flights__..."]: expected shouldFind=true but got found=false
SearchResourceIT:702 top hit "id" instead of "xqz77bfa_exact_rank_target_v1"
The defect is narrower than a whole stage. fuzzyName is an OR multi_match at
70% token coverage and its field list included fullyQualifiedName - which
carries the entire parent path. Querying one entity's FQN therefore clears 70%
against every sibling and child under the same parent, no fuzziness required.
That is the "count 1 vs results 7381" bug, and CI showed it exactly: the
target column matched exactName:fullyQualifiedName, closeName and phraseName,
while the unwanted sibling matched ranking:fuzzyName:text alone.
So drop fullyQualifiedName from fuzzyName and keep the stage. Exact and phrase
identity on an FQN belong to exactName/phraseName, which match it precisely;
fuzzyName keeps name/displayName (+ .compound), which is what finds a mistyped
or half-typed name. The third failure follows from the same edge: since #31106
routed columns through the dataAsset builder, a column competes with its own
table, and a column's FQN contains that table's full name - the column loses
its fuzzy-on-FQN score while the table regains its fuzzy-on-name score.
This also removes the flakiness rather than tolerating it. TestNamespace.RUN_ID
is one static token shared by every entity in a lane, so unrelated columns used
to clear 70% via fullyQualifiedName; against name alone they cannot come near
70% of a ~28-token FQN query.
Verified locally against real Elasticsearch (Docker), which is what this PR was
missing:
- ColumnSearchIndexIT + SearchResourceIT: 78 tests, 0 failures
- with TableResourceIT + DatabaseSchemaResourceIT for concurrent column noise:
610 tests, 0 failures - testColumnFqnSearchIsPrecise,
testDataAssetAliasSearchMatrix and testExactFullNameRanksSeededTableFirst
all pass
- unit: 180 tests green; RED check - restoring fullyQualifiedName fails
testFuzzyNameStageDoesNotRankOnFullyQualifiedName, removing it passes
- spotless:check clean
The three unit tests that pinned the removed heuristic are replaced by three
that pin this invariant, including one asserting the stage still ranks on the
name fields so the previous fix cannot be reintroduced.
Co-Authored-By: Claude Opus 5 <[email protected]>
…opping a stage
Replaces isFuzzyStageUseful. The diagnosis behind it was right — fuzzyName grants
recall, not just score — but the gate acted at query-build time and cost more than
it fixed. getFuzziness() reports 0 for any single-term query past two sub-tokens,
so the gate fired on essentially every entity name and removed the only stage
carrying partial-token recall. Its own lane caught it:
SearchResourceIT:525 medium prefix (autocomplete mid-type)
[query="xqz_lhr__i"]: expected shouldFind=true but got found=false
SearchResourceIT:525 one-char typo inside a segment
[query="...__incaming_flights__..."]: expected shouldFind=true but got found=false
No query-shape rule can separate those two from the bug. Ranking stages sit under
a should with minimum_should_match:1, and fuzzyName is an OR multi_match at partial
token coverage, so anything missing one of the query's tokens clears the threshold:
(T-1)/T exceeds 70% for any realistic T. On an FQN that describes exactly the
target's siblings — but a typo is "one token off" in precisely the same way. Query
text cannot tell them apart, and a bool query cannot either, because "did anything
match by identity" is a property of the result set, not of a document.
So decide it from the result set. Run the ranked query as today, and re-run it
without the fuzzy stage only when a returned document's name or fullyQualifiedName
equals the query — the user asked for that entity by identity, and partial-coverage
recall can then only add its relatives. When nothing matches exactly, the query is
half-typed or misspelled and the stage keeps the role searchSettings.json already
assigns it: a "typo-tolerant identity fallback".
Deliberately keyed on document identity rather than on which stage matched. Stage
provenance is not a usable proxy: closeName is itself a partial-coverage stage, so
an unrelated loose match reads as "precise" and discards a half-typed query's real
target. Re-running rather than filtering hits keeps hits.total consistent with the
list returned; dropping hits client-side would recreate the count/results mismatch
#31106 fixed. The widened query runs first, so an ordinary search still costs one
round-trip and keeps today's results; only an exact identifier lookup pays a second.
This also sits with #29903, which made identity-stage precedence deterministic via
constant_score. Precedence only reorders, so it could not stop a should clause from
admitting siblings; and that PR deliberately invested in tokenCoverage and
partialName carrying recall for imprecise input, which is what the build-time gate
removed.
Verified against real Elasticsearch (postgres-elasticsearch), the step this needed
from the start:
- ColumnSearchIndexIT + SearchResourceIT: 78 tests, 0 failures; all three of
testColumnFqnSearchIsPrecise, testDataAssetAliasSearchMatrix and
testExactFullNameRanksSeededTableFirst pass
- the same suites with the gate still present fail the two scenarios above, which
is how the gate was identified as the cause rather than the fallback
- unit: 187 green, including five cases pinning the trigger (exact FQN, exact name
case-insensitively, half-typed, misspelled, blank)
- spotless:check clean
Co-Authored-By: Claude Opus 5 <[email protected]>
…unts match results (open-metadata#31106) index=tableColumn (the Explore Columns tab) went through buildColumnSearchBuilderV2, a permissive multi_match (best_fields, operator OR) that omitted fqnParts. An FQN query therefore OR-matched every column sharing a parent-name token and returned the whole column index (e.g. 7381), while the dataAsset aggregation that backs the tab count uses the structured builder (operator AND over fqnParts) and correctly returns 1. Route column indexes through buildDataAssetSearchBuilderV2 so they use the existing "tableColumn" AssetTypeConfiguration (fqnParts + AND): an FQN search now matches the one column precisely (count == results) and column-name search still works via the config's name/name.ngram fields. Removes the now-unused buildColumnSearchBuilderV2 from both engine factories. Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Describe your changes:
Fixes open-metadata/openmetadata-collate#3851
The Explore Columns tab shows a count of 1 but the results list shows 7,381 (and Playwright
SearchRBAC › Table Columnfails). Root cause:index=tableColumnresults were built bybuildColumnSearchBuilderV2— a permissivemulti_match(best_fields,operator: OR) that does not searchfqnParts. An FQN query therefore OR-matched every column that shares a parent-name token (service/db/schema/table) and returned the whole column index, while thedataAssetaggregation that backs the tab count uses the structured builder (operator: ANDoverfqnParts) and correctly returns 1.Fix: route column indexes through
buildDataAssetSearchBuilderV2(liketabledoes) so they use the existingtableColumnAssetTypeConfiguration, which already hasfqnParts+ structured match types. An FQN search now matches the one column precisely (count == results), and column-name search still works via the config'sname/name.ngramfields. The now-unusedbuildColumnSearchBuilderV2is removed from both engine factories.Supersedes #31019 (tightening the permissive builder's
minimum_should_matchregressed exact-FQN lookups to 0 hits) and #31093 (matched the badge to the inflated 7,381 instead of fixing the results).Type of change:
Tests:
Unit tests
SearchSourceBuilderFactoryTest#testColumnIndexUsesStructuredDataAssetBuilder—index=tableColumnnow emits a query carryingfqnParts+"operator":"and"(OpenSearch and Elasticsearch).Integration tests
ColumnSearchIndexIT#testColumnFqnSearchIsPrecise— against real OpenSearch, searching a column's full FQN returns exactly that column (total == 1), not its token-sharing siblings.🤖 Generated with Claude Code