Repository navigation
Tune search relevance ranking and debug details - #29853
Conversation
❌ 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 |
✅ TypeScript Types Auto-UpdatedThe generated TypeScript types have been automatically updated based on JSON schema changes in this PR. |
Code Review ✅ Approved 6 resolved / 6 findingsImplements a staged search ranking model that prioritizes asset identity and adds debug visibility to ranking explanations. Issues related to ranking stage collisions and UI display logic have been addressed. ✅ 6 resolved✅ Bug: Ranking details box always shown in Search Preview regardless of toggle
✅ Bug: Search Preview always shows ranking-details box when toggle is off
✅ Edge Case: deriveRanking iterates default stages without null guard
✅ Quality: Exact ranking stage term-matches whole lowercased query against keyword fields
✅ Edge Case: Nameless ranking stages collide and can't clear weight
...and 1 more resolved from earlier reviews OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
🔴 Playwright Results — 7 failure(s), 35 flaky✅ 4520 passed · ❌ 7 failed · 🟡 35 flaky · ⏭️ 37 skipped
Genuine Failures (failed on all attempts)❌
|
| final JsonNode root = JsonUtils.readTree(JsonUtils.pojoToJson(settings)); | ||
| disableRankingNode(root.path("defaultConfiguration")); | ||
|
|
||
| for (JsonNode config : root.path("assetTypeConfigurations")) { |
There was a problem hiding this comment.
These are harder to understand, it's better to use pojo
The staged ranking query in SearchRankingHelper silently dropped matches the
legacy query returned, and it replaces (not augments) that query, so entities
vanished from explore/global search once ranking is default-on after the
migration.
1. significantTokens split the query on every non-alphanumeric character, so an
identifier query like "sample_data" became ["sample", "data"]. Name and FQN
fields keep the identifier intact (keyword fqnParts part "sample_data",
om_analyzer compound token), so the split query matched none of them and
searching a service or database name returned almost nothing. Split on
whitespace only: stop-word removal still applies on word boundaries
("provider address in texas" -> "provider address texas") while identifiers
stay intact and match fqnParts/name compound tokens again.
2. Every derived stage routed name fields through exact/close derivation, both
of which drop .ngram, so no stage carried name.ngram and substring queries
like "ord" stopped matching "orders_fact". Add a partialName n-gram stage and
derive the configured .ngram name fields for it.
Shared helper, so both the Elasticsearch and OpenSearch factories are fixed.
Verified live against OpenSearch: "sample_data" 1 -> 7 hits, "ord" 1 -> 11.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
EntitySearchSettings now opens with the Ranking accordion panel expanded, so the Matching Fields panel and its field-configuration rows are collapsed and unmounted on load. Six SearchSettings and CustomProperties tests that click field-container-header / field-configuration-panel-* timed out. Add openMatchingFieldsPanel() and expand the panel before touching field controls in the affected tests. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
| <Dropdown.Item | ||
| icon={InfoCircle} | ||
| id="show-ranking-details" | ||
| onPress={() => | ||
| onChangeShowRankingDetails?.(!showRankingDetails) | ||
| }> | ||
| <Box justify="between"> | ||
| {t('label.ranking-detail-plural')} | ||
| <Toggle isSelected={showRankingDetails} /> | ||
| </Box> | ||
| </Dropdown.Item> |
| /** Deletes the test case through the action menu + "DELETE" confirm dialog. */ | ||
| public TableDataQualityPage deleteTestCase(final String testCaseName) { | ||
| byTestId("action-dropdown-" + testCaseName).click(); | ||
| byTestId("delete-" + testCaseName).click(); | ||
| page.locator("#deleteTextInput").fill("DELETE"); | ||
| byTestId("confirm-button") |
The partialName stage queries name.ngram/displayName.ngram, which are indexed with an edge-n-gram analyzer. Querying them with that same analyzer re-n-grams the query text, so a long single token (e.g. a 36-char camelCase name) expands to ~460 terms per field. Stacked on the other ranked stages this exceeds OpenSearch's default maxClauseCount of 1024 and the whole search fails with too_many_nested_clauses (SearchResourceIT "long camelCase single token"). Elasticsearch 8 dropped the hard cap, so only OpenSearch tripped. Query n-gram-only stages with a plain "standard" analyzer (the canonical edge-n-gram pattern): the query stays one token and still matches the indexed n-grams, so "ord" still finds "orders_fact" while the stage's clause count drops from ~900 to ~2. Applied via the shared multiMatchQuery for both the Elasticsearch and OpenSearch factories. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
| const deriveStructuralFields = ( | ||
| configuredFields: string[], | ||
| fallbackFields: string[] | ||
| ) => { | ||
| const fields = new Set( | ||
| configuredFields.filter( | ||
| (field) => | ||
| !isPrimaryNameField(field) && | ||
| !isDescriptionContextField(field) && | ||
| !field.startsWith('extension.') | ||
| ) | ||
| ); | ||
|
|
||
| return withFallbackFields(fields, fallbackFields); | ||
| }; | ||
|
|
||
| const deriveRankingStageFields = ( | ||
| stage: RankingStage, | ||
| configuredFields: string[] |
There was a problem hiding this comment.
Missing
partial/ngram branch causes wrong fields for the partialName stage
deriveRankingStageFields omits the partial/ngram case that exists in the Java SearchRankingHelper.deriveFieldsForStage. For a stage named "partialName", stageName.includes('name') is true, so the function returns close-name fields (displayName, name, displayName.compound, …) instead of ngram fields (displayName.ngram, name.ngram). When a user opens the Entity Search Settings page and saves without edits, this derived config is sent as the entity-specific ranking config, overwriting the default and silently replacing the ngram fields with the analyzed fields — breaking partial-name / prefix search for that entity type thereafter.
The Java counterpart guards this correctly: if (stageName.contains("partial") || stageName.contains("ngram")). The fix is to add the same guard before the includes('name') check in TypeScript.
| const stageName = (stage.name ?? '').toLowerCase(); | ||
|
|
||
| if (stageName.includes('exact')) { | ||
| return deriveExactNameFields(configuredFields, fallbackFields); | ||
| } | ||
| if (stageName.includes('close') || stageName.includes('name')) { | ||
| return deriveCloseNameFields(configuredFields, fallbackFields); | ||
| } | ||
| if (stageName.includes('description')) { | ||
| return deriveDescriptionFields(configuredFields, fallbackFields); | ||
| } | ||
|
|
||
| return deriveStructuralFields(configuredFields, fallbackFields); |
| onChangeShowRankingDetails?.(!showRankingDetails) | ||
| }> | ||
| <Box justify="between"> | ||
| {t('label.ranking-detail-plural')} | ||
| <Toggle isSelected={showRankingDetails} /> | ||
| </Box> |
|
|
Code Review ✅ Approved 6 resolved / 6 findingsImplements a staged search ranking model with configurable scoring stages and enhanced debug visibility. Resolved all open findings, including the ranking details toggle issue and various null-safety and collision bugs. ✅ 6 resolved✅ Bug: Ranking details box always shown in Search Preview regardless of toggle
✅ Bug: Search Preview always shows ranking-details box when toggle is off
✅ Edge Case: deriveRanking iterates default stages without null guard
✅ Quality: Exact ranking stage term-matches whole lowercased query against keyword fields
✅ Edge Case: Nameless ranking stages collide and can't clear weight
...and 1 more resolved from earlier reviews OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |



Describe your changes:
Fixes: N/A (issue not provided)
This PR adds a staged search ranking model that prioritizes exact/close asset identity matches, then structural context, then description matches, with Tier, Usage, and votes capped as tie-breaker signals. It also adds readable ranking debug details in search/search settings, migrates existing 2.0.0 search settings, and expands sample data plus Playwright coverage for relevance cases like
provider address in texas.Type of change:
High-level design:
rankingmodel tosearchSettings.jsonwith ordered stages for exact name, close name, structural context, and description context.matched_queries, localized labels, and Search Settings preview/debug support.Tests:
Use cases covered
indo not cause weak descriptive matches to outrank clearer table-name intent.Unit tests
ExploreSearchCard.test.tsxBackend integration tests
openmetadata-integration-tests/for new/changed API endpoints.Ingestion integration tests
Playwright (UI) tests
openmetadata-ui/.../ui/playwright/for UI changes.SearchRelevance.spec.tsManual testing performed
SearchIndexingApplication.provider address in texasranksprovider_address_texas,provider_address, and structural matches above Tier1/high-usage description-only fixtures.mvn -pl openmetadata-service spotless:apply.mvn -DonlyBackend -pl openmetadata-service -am -DskipTests package.npx -y [email protected] ./node_modules/jest/bin/jest.js src/components/ExploreV1/ExploreSearchCard/ExploreSearchCard.test.tsx --runInBand.npx -y [email protected] ./node_modules/.bin/playwright test playwright/e2e/Search/SearchRelevance.spec.ts --project=search-nightly.UI screen recording / screenshots:
Not attached; ranking details and side-panel sizing were verified locally with focused UI tests and the local Docker search flow.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.Greptile Summary
This PR introduces a staged search ranking model that prioritises exact/close identity matches, then structural context, then description matches, with Tier, Usage, and vote signals capped as tie-breakers. It adds user-readable ranking debug details in search results and settings, migrates existing 2.0.0 search settings, and extends Playwright coverage for relevance scenarios.
SearchRankingHelpertranslates aRankingConfigurationinto Elasticsearch/OpenSearchdis_maxqueries with named clauses;SearchSettingsHandlervalidates the new config;MigrationUtilbackfills the ranking section into stored settings.ExploreSearchCardrenders matched stage labels and score contributors when "Ranking Details" is toggled;EntitySearchSettingsexposes per-stage weight and signal controls.SearchRankingHelperTestandSearchSettingsUtils.test.tscover stop-word filtering and stage derivation; a newSearchRelevance.spec.tsPlaywright shard is added.Confidence Score: 4/5
Safe to merge after fixing the TypeScript stage-field derivation divergence; all other changes are additive and well-tested.
The
deriveRankingStageFieldsfunction in TypeScript is missing thepartial/ngrambranch present in the Java counterpart. Because"partialname".includes('name')is true, thepartialNamestage is classified as close-name and given analysed fields instead of ngram fields. If a user opens and saves entity search settings without edits, this incorrect config is persisted, overwriting the default and breaking partial-name search for that entity.openmetadata-ui/src/main/resources/ui/src/utils/SearchSettingsUtils.ts —
deriveRankingStageFieldsneeds apartial/ngrambranch added before theincludes('name')check.Important Files Changed
getEffectiveRankingConfigurationand stage-field derivation helpers added. Missingpartial/ngrambranch causes thepartialNamestage to be misclassified as close-name, potentially corrupting a saved entity ranking config.maxBoostforwarded tofunctionScoreQuery.backfillSearchRankingSettingsmigration that gracefully handles null settings and merges missing ranking stages.showRankingDetailsis enabled; depth-limited recursive explanation traversal is safe.Switchfor the enabled toggle instead of the coreTogglecomponent.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD Q[User Search Query] --> RSH[SearchRankingHelper] RSH -->|resolveRanking| RC{RankingConfiguration?} RC -->|yes| SQ[significantQueryText remove stop-words] RC -->|no| LQ[Legacy query path] SQ --> STAGES[Iterate RankingStages] STAGES -->|EXACT| EQ[buildExactRankingStageQuery] STAGES -->|PHRASE| PQ[buildPhraseRankingStageQuery] STAGES -->|FUZZY| FQ[buildTextRankingStageQuery + fuzziness] STAGES -->|STANDARD| TQ[buildTextRankingStageQuery] EQ & PQ & FQ & TQ --> DM[dis_max query with tieBreaker] DM --> FS[functionScoreQuery Tier+Usage+Votes capped by maxBoost] FS --> ES[(Elasticsearch / OpenSearch)] ES -->|matched_queries| UI[ExploreSearchCard Ranking Details] ES -->|_explanation| UI%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% flowchart TD Q[User Search Query] --> RSH[SearchRankingHelper] RSH -->|resolveRanking| RC{RankingConfiguration?} RC -->|yes| SQ[significantQueryText remove stop-words] RC -->|no| LQ[Legacy query path] SQ --> STAGES[Iterate RankingStages] STAGES -->|EXACT| EQ[buildExactRankingStageQuery] STAGES -->|PHRASE| PQ[buildPhraseRankingStageQuery] STAGES -->|FUZZY| FQ[buildTextRankingStageQuery + fuzziness] STAGES -->|STANDARD| TQ[buildTextRankingStageQuery] EQ & PQ & FQ & TQ --> DM[dis_max query with tieBreaker] DM --> FS[functionScoreQuery Tier+Usage+Votes capped by maxBoost] FS --> ES[(Elasticsearch / OpenSearch)] ES -->|matched_queries| UI[ExploreSearchCard Ranking Details] ES -->|_explanation| UIReviews (17): Last reviewed commit: "Fix OpenSearch maxClauseCount blowup fro..." | Re-trigger Greptile