Skip to content

Tune search relevance ranking and debug details - #29853

Merged
harshach merged 17 commits into
mainfrom
harshach/tune-search-relevance-debug
Jul 9, 2026
Merged

harshach merged 17 commits into
mainfrom
harshach/tune-search-relevance-debug

Conversation

@harshach

@harshach harshach commented Jul 8, 2026 •

Copy link
Copy Markdown
Collaborator

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:

  • Bug fix
  • Improvement
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

High-level design:

  • Adds a high-level ranking model to searchSettings.json with ordered stages for exact name, close name, structural context, and description context.
  • Translates the staged ranking model into Elasticsearch/OpenSearch queries while keeping asset-level field/weight tuning configurable.
  • Applies Tier, Usage, and vote signals with capped additive scoring so they do not outrank stronger lexical identity matches.
  • Adds user-readable ranking explanations backed by matched_queries, localized labels, and Search Settings preview/debug support.
  • Adds 2.0.0 migrations to upgrade stored search settings with the new ranking section.
  • Adds a dedicated SearchRelevance Playwright shard in PR and MySQL/PostgreSQL nightly E2E workflows.

Tests:

Use cases covered

  • Exact or close asset-name matches rank above description-only matches.
  • Column/structural matches rank above weak high-tier/high-usage description matches.
  • Stopwords like in do not cause weak descriptive matches to outrank clearer table-name intent.
  • Ranking details explain why a result matched and which signals were applied.

Unit tests

  • I added unit tests for the new/changed logic.
  • Files added/updated: ExploreSearchCard.test.tsx
  • Coverage %: not collected for this focused run.

Backend integration tests

  • I added integration tests in openmetadata-integration-tests/ for new/changed API endpoints.
  • Not applicable (no new backend API endpoint).

Ingestion integration tests

  • I added/updated ingestion integration tests for connector changes.
  • Not applicable (sample data fixtures only).

Playwright (UI) tests

  • I added Playwright E2E tests under openmetadata-ui/.../ui/playwright/ for UI changes.
  • Files added/updated: SearchRelevance.spec.ts

Manual testing performed

  1. Refreshed local Docker sample data and usage, then triggered SearchIndexingApplication.
  2. Verified provider address in texas ranks provider_address_texas, provider_address, and structural matches above Tier1/high-usage description-only fixtures.
  3. Ran mvn -pl openmetadata-service spotless:apply.
  4. Ran UI checkstyle sequence on changed UI source and Playwright files.
  5. Ran mvn -DonlyBackend -pl openmetadata-service -am -DskipTests package.
  6. Ran npx -y [email protected] ./node_modules/jest/bin/jest.js src/components/ExploreV1/ExploreSearchCard/ExploreSearchCard.test.tsx --runInBand.
  7. Ran npx -y [email protected] ./node_modules/.bin/playwright test playwright/e2e/Search/SearchRelevance.spec.ts --project=search-nightly.
  8. Validated the updated workflow YAML files and listed the new SearchRelevance shard command with Playwright.

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:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.
  • For UI changes: I attached a screen recording and/or screenshots above.
  • I have added tests (unit / integration / Playwright as applicable) and listed them 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.

  • Backend: New SearchRankingHelper translates a RankingConfiguration into Elasticsearch/OpenSearch dis_max queries with named clauses; SearchSettingsHandler validates the new config; MigrationUtil backfills the ranking section into stored settings.
  • UI: ExploreSearchCard renders matched stage labels and score contributors when "Ranking Details" is toggled; EntitySearchSettings exposes per-stage weight and signal controls.
  • Data & tests: Sample fixtures expanded with relevance-test entities; SearchRankingHelperTest and SearchSettingsUtils.test.ts cover stop-word filtering and stage derivation; a new SearchRelevance.spec.ts Playwright 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 deriveRankingStageFields function in TypeScript is missing the partial/ngram branch present in the Java counterpart. Because "partialname".includes('name') is true, the partialName stage 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 — deriveRankingStageFields needs a partial/ngram branch added before the includes('name') check.

Important Files Changed

Filename Overview
openmetadata-ui/src/main/resources/ui/src/utils/SearchSettingsUtils.ts New getEffectiveRankingConfiguration and stage-field derivation helpers added. Missing partial/ngram branch causes the partialName stage to be misclassified as close-name, potentially corrupting a saved entity ranking config.
openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRankingHelper.java New helper class encapsulating all ranking resolution, stop-word filtering, significant-token extraction, and field-derivation logic. Well-structured with tests.
openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchSourceBuilderFactory.java Cleanup of fully-qualified type references; new staged ranking query builder wired in with maxBoost forwarded to functionScoreQuery.
openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v200/MigrationUtil.java Adds backfillSearchRankingSettings migration that gracefully handles null settings and merges missing ranking stages.
openmetadata-ui/src/main/resources/ui/src/components/ExploreV1/ExploreSearchCard/ExploreSearchCard.tsx Adds ranking details panel when showRankingDetails is enabled; depth-limited recursive explanation traversal is safe.
openmetadata-ui/src/main/resources/ui/src/components/SearchSettings/EntitySeachSettings/EntitySearchSettings.tsx Adds ranking configuration section. Uses antd Switch for the enabled toggle instead of the core Toggle component.
openmetadata-service/src/main/java/org/openmetadata/service/resources/system/SearchSettingsHandler.java Adds validation for ranking stages and signals (maxBoost > 0). Correctly rejects zero maxBoost values.

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
Loading
%%{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| UI
Loading

Reviews (17): Last reviewed commit: "Fix OpenSearch maxClauseCount blowup fro..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Jul 8, 2026
@harshach
harshach marked this pull request as ready for review July 8, 2026 18:49
@harshach
harshach requested review from a team, akash-jain-10 and tutte as code owners July 8, 2026 18:49
Copilot AI review requested due to automatic review settings July 8, 2026 18:49
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 skip-pr-checks label.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

✅ TypeScript Types Auto-Updated

The generated TypeScript types have been automatically updated based on JSON schema changes in this PR.

Copilot AI review requested due to automatic review settings July 8, 2026 18:54
@harshach
harshach removed the request for review from Copilot July 8, 2026 18:54
@github-actions

github-actions Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 63%
63.59% (72722/114357) 46.69% (42295/90577) 48.08% (13035/27110)

Copilot AI review requested due to automatic review settings July 8, 2026 19:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gitar-bot

gitar-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 6 resolved / 6 findings

Implements 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

📄 openmetadata-ui/src/main/resources/ui/src/components/SearchSettings/SearchPreview/SearchPreview.tsx:134-135 📄 openmetadata-ui/src/main/resources/ui/src/components/ExploreV1/ExploreSearchCard/ExploreSearchCard.tsx:476-490 📄 openmetadata-ui/src/main/resources/ui/src/components/SearchedData/SearchedData.tsx:67-69
In ExploreSearchCard.tsx, the new ranking-details block renders when rankingStages.length > 0 || score !== undefined. In the Explore flow (SearchedData.tsx) both score and matchedQueries are gated on showRankingDetails (passed as undefined when the toggle is off), so the box is correctly hidden. However, in SearchPreview.tsx the score is passed unconditionally (score={_score}) while only matchedQueries is gated on showRankingDetails. As a result, when the 'Ranking Details' switch is OFF in Search Settings preview, score !== undefined is still true and the ranking-details container renders (showing the header and the generic signals-explanation text with no stages). This defeats the purpose of the toggle and shows debug UI to admins who did not enable it. Gate the score the same way as in the Explore flow.

✅ Bug: Search Preview always shows ranking-details box when toggle is off

📄 openmetadata-ui/src/main/resources/ui/src/components/SearchSettings/SearchPreview/SearchPreview.tsx:124-138 📄 openmetadata-ui/src/main/resources/ui/src/components/ExploreV1/ExploreSearchCard/ExploreSearchCard.tsx:476
In SearchPreview, matched_queries is correctly gated behind showRankingDetails (matchedQueries={showRankingDetails ? matched_queries : undefined}), but score={_score} is passed unconditionally. ExploreSearchCard renders the ranking-details container whenever rankingStages.length > 0 || score !== undefined. Because _score is essentially always defined for a search hit, the ranking-details box (with the 'search-ranking-signals-explanation' text) is always rendered in Search Preview even when the 'Ranking Details' switch is off. This contradicts the intent of the toggle and is inconsistent with the Explore path (SearchedData.tsx), which gates score with score={showRankingDetails ? _score : undefined}. Gate the score the same way in SearchPreview.

✅ Edge Case: deriveRanking iterates default stages without null guard

📄 openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRankingHelper.java:114-121
SearchRankingHelper.deriveRanking does for (RankingStage stage : defaultRanking.getStages()) without a null check. RankingConfiguration.stages is not a required property in the schema (searchSettings.json defines required: ["name","fields"] only on rankingStage, not stages on rankingConfiguration), so an admin-saved default configuration with enabled: true but no stages would reach this loop with a null list and throw a NullPointerException during query building. SearchSettingsHandler.validateRanking does reject empty/absent stages for enabled rankings, which mitigates the persisted path, but the helper is otherwise defensive (it uses nullOrEmpty/listOrEmpty elsewhere). Wrap the iteration in listOrEmpty(...) for consistency and robustness.

✅ Quality: Exact ranking stage term-matches whole lowercased query against keyword fields

📄 openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchSourceBuilderFactory.java:665-675
buildExactRankingStageQueryV2 builds a term query using the entire lowercased user query (query.toLowerCase(Locale.ROOT)) against exact-stage fields, which include .keyword sub-fields (e.g. displayName.keyword, name.keyword) and fullyQualifiedName. A term query on a keyword field is an exact, case-sensitive token match against the stored value unless a lowercasing normalizer is configured on that field. Two consequences worth confirming: (1) for a multi-word query like provider address texas the term will only match a document whose keyword value is literally the full string, so the 'exact identity' stage will not fire for the intended provider_address_texas table; (2) if the keyword fields are not normalized to lowercase at index time, lowercasing the query guarantees a mismatch against mixed-case stored values. Please verify the field mappings apply a lowercase normalizer, and confirm the exact-stage semantics match the intended behavior described in the PR (exact/close asset-name matches ranking first).

✅ Edge Case: Nameless ranking stages collide and can't clear weight

📄 openmetadata-ui/src/main/resources/ui/src/components/SearchSettings/EntitySeachSettings/EntitySearchSettings.tsx:368-382 📄 openmetadata-ui/src/main/resources/ui/src/components/SearchSettings/EntitySeachSettings/EntitySearchSettings.tsx:691-705
The rendering now falls back to stageName = stage.name ?? '' for the React key, data-testid, and the value passed to handleRankingStageWeightChange. Two problems arise if more than one stage lacks a name (the scenario the new SearchSettingsUtils test explicitly covers as possible runtime data):

  1. React key/testid collision: all nameless stages render with key='' and data-testid='ranking-stage-', which produces duplicate-key warnings and can cause stale/incorrect re-renders.
  2. Weight edits silently no-op: handleRankingStageWeightChange matches with stage.name === stageName, but it is invoked with stageName = stage.name ?? ''. When stage.name is undefined, the comparison undefined === '' is false, so the weight change (including clearing) is dropped.

Since name is optional in the RankingStage schema, consider keying stages by index (or a stable synthesized id) and passing the same identity to the weight handler so nameless stages behave predictably. This is a minor edge case given nameless stages are unusual in practice.

...and 1 more resolved from earlier reviews

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

pmbrull
pmbrull previously approved these changes Jul 9, 2026
@github-actions

github-actions Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

🔴 Playwright Results — 7 failure(s), 35 flaky

✅ 4520 passed · ❌ 7 failed · 🟡 35 flaky · ⏭️ 37 skipped

Shard Passed Failed Flaky Skipped
🔴 Shard 1 424 1 2 16
🟡 Shard 2 821 0 8 3
🟡 Shard 3 812 0 8 12
🟡 Shard 4 824 0 1 5
🔴 Shard 5 866 1 4 0
🔴 Shard 6 773 5 12 1

Genuine Failures (failed on all attempts)

❌ Flow/Tour.spec.ts › Tour should work from help section (shard 1)
TimeoutError: locator.waitFor: Timeout 10000ms exceeded.
Call log:
�[2m  - waiting for locator('[data-tour-elem="badge"]') to be visible�[22m

❌ Pages/Domains.spec.ts › Verify domain and subdomain asset count accuracy (shard 5)
Error: �[2mexpect(�[22m�[31mreceived�[39m�[2m).�[22mtoBe�[2m(�[22m�[32mexpected�[39m�[2m) // Object.is equality�[22m

Expected: �[32m6�[39m
Received: �[31m0�[39m
❌ Pages/Glossary.spec.ts › Request description task for Glossary Term (shard 6)
Error: �[2mexpect(�[22m�[31mreceived�[39m�[2m).�[22mtoContain�[2m(�[22m�[32mexpected�[39m�[2m) // indexOf�[22m

Expected substring: �[32m"Updated description"�[39m
Received string:    �[31m""�[39m
❌ Pages/ODCSImportExport.spec.ts › Import full ODCS contract with all sections from test-data file (shard 6)
�[31mTest timeout of 180000ms exceeded.�[39m
❌ Pages/ODCSImportExport.spec.ts › Import ODCS contract with SLA properties from test-data file (shard 6)
�[31mTest timeout of 180000ms exceeded.�[39m
❌ Pages/ODCSImportExport.spec.ts › Import ODCS, modify via UI, export and verify changes (shard 6)
�[31mTest timeout of 180000ms exceeded.�[39m
❌ Pages/SearchSettings.spec.ts › Configure column search field settings (shard 6)
�[31mTest timeout of 60000ms exceeded.�[39m
🟡 35 flaky test(s) (passed on retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab IS visible for supported type: metric (shard 1, 1 retry)
  • Flow/SearchRBAC.spec.ts › the browse tree only shows the asset-type categories a user can access (shard 1, 1 retry)
  • Features/BulkEditEntity.spec.ts › Glossary (shard 2, 1 retry)
  • Features/BulkEditEntity.spec.ts › Glossary Term (Nested) (shard 2, 1 retry)
  • Features/BulkEditOperationBadges.spec.ts › Database service bulk edit search filters rows and clear restores them (shard 2, 1 retry)
  • Features/ContextCenterArticles.spec.ts › Article listing search filters, clears, and shows empty state (shard 2, 1 retry)
  • Features/ContextCenterArticles.spec.ts › Article list cards, recently viewed widget, and pagination work (shard 2, 1 retry)
  • Features/ContextCenterMemories.spec.ts › ArrowDown + Enter keyboard navigation selects the linked table result (shard 2, 1 retry)
  • Features/ContextCenterPermission.spec.ts › user with editAll permission can see restore action but not delete action on an archived document, and can restore it (shard 2, 1 retry)
  • Features/ContextCenterPermission.spec.ts › selecting "Updated By" actually reorders rows by updatedBy (shard 2, 1 retry)
  • Features/Glossary/GlossaryP3Tests.spec.ts › should show error state when navigating to non-existent glossary (shard 3, 1 retry)
  • Features/Glossary/GlossaryRelationsGraph.spec.ts › search in the Relations Graph filters to the matching node and its neighbours (shard 3, 2 retries)
  • Features/Glossary/GlossaryRemoveOperations.spec.ts › should add and remove tags from glossary term (shard 3, 1 retry)
  • Features/Glossary/GlossaryTermRelationsGraphNested.spec.ts › viewing a child term: parentOf edge is rendered between parent and child (shard 3, 2 retries)
  • Features/Glossary/LargeGlossaryPerformance.spec.ts › should handle drag and drop for term reordering (shard 3, 1 retry)
  • Features/LandingPageWidgets/DomainDataProductsWidgets.spec.ts › Data Product asset count should update when assets are removed (shard 3, 1 retry)
  • Features/SearchExport.spec.ts › Export queues a background job and downloads from the jobs tray (shard 3, 1 retry)
  • Features/SSOConfiguration.spec.ts › should show correct fields when selecting Auth0 provider (shard 3, 1 retry)
  • Flow/PersonaFlow.spec.ts › Set default persona for team should work properly (shard 4, 1 retry)
  • Pages/Entity.spec.ts › Update description (shard 5, 1 retry)
  • Pages/Entity.spec.ts › Tier Add, Update and Remove (shard 5, 1 retry)
  • Pages/EntityDataSteward.spec.ts › Update description (shard 5, 1 retry)
  • Pages/ExplorePageRightPanel_KnowledgeCenter.spec.ts › Should remove user owner for knowledgeCenter (shard 5, 1 retry)
  • Pages/ExplorePageRightPanel.spec.ts › Should allow Data Steward to edit glossary terms for searchIndex (shard 6, 1 retry)
  • Pages/Glossary.spec.ts › Create term with related terms, tags and owners during creation (shard 6, 1 retry)
  • Pages/Lineage/LineageFilters.spec.ts › Verify Impact Analysis service filter selection (shard 6, 1 retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab is NOT visible for pipelineService in platform lineage (shard 6, 1 retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab is NOT visible for apiService in platform lineage (shard 6, 1 retry)
  • Pages/ODCSImportExport.spec.ts › Import basic ODCS contract from test-data file (shard 6, 1 retry)
  • Pages/ODCSImportExport.spec.ts › Import ODCS contract with draft status from test-data file (shard 6, 1 retry)
  • ... and 5 more

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

final JsonNode root = JsonUtils.readTree(JsonUtils.pojoToJson(settings));
disableRankingNode(root.path("defaultConfiguration"));

for (JsonNode config : root.path("assetTypeConfigurations")) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are harder to understand, it's better to use pojo

pmbrull and others added 2 commits July 9, 2026 14:33
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]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 78 out of 81 changed files in this pull request and generated 2 comments.

Comment on lines +795 to +805
<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>
Comment on lines 242 to +246
/** 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]>
Comment on lines +163 to +181
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[]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 78 out of 81 changed files in this pull request and generated 2 comments.

Comment on lines +189 to +201
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);
Comment on lines +799 to +804
onChangeShowRankingDetails?.(!showRankingDetails)
}>
<Box justify="between">
{t('label.ranking-detail-plural')}
<Toggle isSelected={showRankingDetails} />
</Box>
@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

@gitar-bot

gitar-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 6 resolved / 6 findings

Implements 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

📄 openmetadata-ui/src/main/resources/ui/src/components/SearchSettings/SearchPreview/SearchPreview.tsx:134-135 📄 openmetadata-ui/src/main/resources/ui/src/components/ExploreV1/ExploreSearchCard/ExploreSearchCard.tsx:476-490 📄 openmetadata-ui/src/main/resources/ui/src/components/SearchedData/SearchedData.tsx:67-69
In ExploreSearchCard.tsx, the new ranking-details block renders when rankingStages.length > 0 || score !== undefined. In the Explore flow (SearchedData.tsx) both score and matchedQueries are gated on showRankingDetails (passed as undefined when the toggle is off), so the box is correctly hidden. However, in SearchPreview.tsx the score is passed unconditionally (score={_score}) while only matchedQueries is gated on showRankingDetails. As a result, when the 'Ranking Details' switch is OFF in Search Settings preview, score !== undefined is still true and the ranking-details container renders (showing the header and the generic signals-explanation text with no stages). This defeats the purpose of the toggle and shows debug UI to admins who did not enable it. Gate the score the same way as in the Explore flow.

✅ Bug: Search Preview always shows ranking-details box when toggle is off

📄 openmetadata-ui/src/main/resources/ui/src/components/SearchSettings/SearchPreview/SearchPreview.tsx:124-138 📄 openmetadata-ui/src/main/resources/ui/src/components/ExploreV1/ExploreSearchCard/ExploreSearchCard.tsx:476
In SearchPreview, matched_queries is correctly gated behind showRankingDetails (matchedQueries={showRankingDetails ? matched_queries : undefined}), but score={_score} is passed unconditionally. ExploreSearchCard renders the ranking-details container whenever rankingStages.length > 0 || score !== undefined. Because _score is essentially always defined for a search hit, the ranking-details box (with the 'search-ranking-signals-explanation' text) is always rendered in Search Preview even when the 'Ranking Details' switch is off. This contradicts the intent of the toggle and is inconsistent with the Explore path (SearchedData.tsx), which gates score with score={showRankingDetails ? _score : undefined}. Gate the score the same way in SearchPreview.

✅ Edge Case: deriveRanking iterates default stages without null guard

📄 openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRankingHelper.java:114-121
SearchRankingHelper.deriveRanking does for (RankingStage stage : defaultRanking.getStages()) without a null check. RankingConfiguration.stages is not a required property in the schema (searchSettings.json defines required: ["name","fields"] only on rankingStage, not stages on rankingConfiguration), so an admin-saved default configuration with enabled: true but no stages would reach this loop with a null list and throw a NullPointerException during query building. SearchSettingsHandler.validateRanking does reject empty/absent stages for enabled rankings, which mitigates the persisted path, but the helper is otherwise defensive (it uses nullOrEmpty/listOrEmpty elsewhere). Wrap the iteration in listOrEmpty(...) for consistency and robustness.

✅ Quality: Exact ranking stage term-matches whole lowercased query against keyword fields

📄 openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchSourceBuilderFactory.java:665-675
buildExactRankingStageQueryV2 builds a term query using the entire lowercased user query (query.toLowerCase(Locale.ROOT)) against exact-stage fields, which include .keyword sub-fields (e.g. displayName.keyword, name.keyword) and fullyQualifiedName. A term query on a keyword field is an exact, case-sensitive token match against the stored value unless a lowercasing normalizer is configured on that field. Two consequences worth confirming: (1) for a multi-word query like provider address texas the term will only match a document whose keyword value is literally the full string, so the 'exact identity' stage will not fire for the intended provider_address_texas table; (2) if the keyword fields are not normalized to lowercase at index time, lowercasing the query guarantees a mismatch against mixed-case stored values. Please verify the field mappings apply a lowercase normalizer, and confirm the exact-stage semantics match the intended behavior described in the PR (exact/close asset-name matches ranking first).

✅ Edge Case: Nameless ranking stages collide and can't clear weight

📄 openmetadata-ui/src/main/resources/ui/src/components/SearchSettings/EntitySeachSettings/EntitySearchSettings.tsx:368-382 📄 openmetadata-ui/src/main/resources/ui/src/components/SearchSettings/EntitySeachSettings/EntitySearchSettings.tsx:691-705
The rendering now falls back to stageName = stage.name ?? '' for the React key, data-testid, and the value passed to handleRankingStageWeightChange. Two problems arise if more than one stage lacks a name (the scenario the new SearchSettingsUtils test explicitly covers as possible runtime data):

  1. React key/testid collision: all nameless stages render with key='' and data-testid='ranking-stage-', which produces duplicate-key warnings and can cause stale/incorrect re-renders.
  2. Weight edits silently no-op: handleRankingStageWeightChange matches with stage.name === stageName, but it is invoked with stageName = stage.name ?? ''. When stage.name is undefined, the comparison undefined === '' is false, so the weight change (including clearing) is dropped.

Since name is optional in the RankingStage schema, consider keying stages by index (or a stable synthesized id) and passing the same identity to the weight handler so nameless stages behave predictably. This is a minor edge case given nameless stages are unusual in practice.

...and 1 more resolved from earlier reviews

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

This branch was previously deployed

1 inactive deployment
test — 5bc33d0b Deployed Jul 9, 2026 by pmbrull via playwright-ci-postgresql (3, 6) #55613
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants