Skip to content

feat(search): add data_contract_search_index - #34304

Merged
Khairajani merged 17 commits into
mainfrom
feat/data-contract-search-index
Oct 15, 2026
Merged

Khairajani merged 17 commits into
mainfrom
feat/data-contract-search-index

Conversation

@karanh37

Copy link
Copy Markdown
Contributor

Describe your changes:

Data contracts are a first-class entity (own table, API and FQN, linked asset --CONTAINS--> dataContract) but had no search index, so nothing could select them with a search query. This adds data_contract_search_index so contracts can be filtered by search — the immediate consumer is governance automations, which select entities through ES/OpenSearch query filters and need to bulk-update owners and descriptions on contracts.

Type of change:

  • New feature

High-level design:

Index registration — dataContract in indexMapping.json with alias dataContract and no parent aliases (same placement as ingestionPipeline):

  • not dataAsset, so contracts stay out of Explore and search-bar suggestions;
  • not all, because team/user asset lists and the domain / tag / data-product asset pickers query all, where a contract would be listed with no link and accepted as a domain or tag asset it cannot hold;
  • not a childAlias of any asset: the child cascade deletes by <parentType>.id while contracts store entity.id. The contract's own lifecycle events already delete/update its doc when the asset is soft-deleted, restored or hard-deleted (descendantsCoveredByAncestorCascade stays false).

Mappings — elasticsearch/{en,jp,ru,zh}/data_contract_index_mapping.json, each built from that language's own analysis settings. Common entity fields plus entity / testSuite references (FQN keyword lowercase-normalized, no ignore_above so long asset FQNs stay filterable), latestResult, reviewers, effective dates, fqnHash.

Document builder — DataContractIndex (a SearchIndex, not TaggableIndex — contracts have no tags) adds entity and testSuite; everything else comes from populateCommonFields. It excludes the large or free-form blocks (schema, semantics, qualityExpectations, odcsQualityRules, odcsElementExtensions, contractUpdates, sla, security, termsOfUse) to avoid mapping explosion.

Fix uncovered by indexing — DataContractRepository.updateLatestResult PATCHed a copy of a contract fetched without owners/reviewers (daily validation app, POST /results, POST /validate). Harmless before, but with an index the reindex after that PATCH blanked owners and reviewers in every contract doc. It now reloads owners,reviewers,extension first and only changes latestResult.

Python — ES_INDEX_MAP and ENTITY_REFERENCE_CLASS_MAP gain DataContract, so paginate_es(DataContract, …) works and get_entity_type(DataContract) returns dataContract (was the lowercase fallback datacontract).

UI — SearchIndex.DATA_CONTRACT, both SearchClassBase mappings (no Explore tab — tabs come from getTabsInfo), DataContractSearchSource, and query-builder fields for the contract index: asset type (entity.type), asset (entity.fullyQualifiedName.keyword), contract execution status (latestResult.status) and reviewers. Status, owners, name and description come from the common config.

Rollout — the index is created at startup. Contracts that already exist are not in it until Search Indexing runs once with entities: ["dataContract"] (or all).

Tests:

Use cases covered

  • A contract is indexed on create, updated on description/owner change and removed or flagged on delete.
  • Recording a contract result keeps the contract's owners in its search document.
  • A contract with no owners, reviewers, test suite or latest result builds a document without errors.
  • Large contract blocks never reach the document, and every document key is declared in the mapping.

Unit tests

  • DataContractIndexMappingTest (new): registration, contract fields in all 4 languages, no ignore_above on asset FQN, lowercase-normalized FQN keywords, free-form blocks and tags not mapped.
  • DataContractIndexTest (new): entity reference with display name, minimal contract, excluded blocks, every doc key mapped.
  • SearchIndexFactoryTest, EntityTypeNameTest: new rows.
  • test_ometa_utils.py: get_entity_type(DataContract) and ES_INDEX_MAP entry.
  • SearchClassBase.test.ts, AdvancedSearchClassBase.test.ts: mappings and query-builder fields.
  • Existing mapping guards pass: IndexMappingNestedFieldConsistencyTest, IndexAnalyzerMappingTest, SearchDocFieldValidationTest, SearchSettingsHandlerTest, SearchRepository*Test.

Backend integration tests

  • DataContractResourceIT: supportsSearchIndex = true (enables checkCreatedEntity, checkDeletedEntity, checkIndexCreated, updateDescriptionAndCheckInSearch, testSearchFluentAPI), plus patchOwners_reindexesContract and addResult_keepsOwnersInSearchDoc. Local run: 396 tests, 0 failures.

Ingestion integration tests

  • Not applicable.

Playwright (UI) tests

  • Not applicable (no user-facing UI change; query-builder fields are only reachable from consumers that target the contract index).

UI screen recording / screenshots:

Not applicable.

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. (No entity schema change; new index mapping only — see Rollout.)
  • 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.

🤖 Generated with Claude Code

karanh37 and others added 6 commits September 30, 2026 17:37
Recording a contract result PATCHed a copy fetched without owners and
reviewers, so the reindex blanked them in every contract doc. Reload the
relationship fields first.

Keep the index out of the all alias: team and user asset lists and the
domain, tag and data product pickers query all, where contracts would
show with no link and be accepted as assets they cannot hold.

Lowercase-normalize the entity and testSuite FQN keywords so the asset
autocomplete matches mixed-case FQNs.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels Sep 30, 2026
karanh37 and others added 8 commits September 30, 2026 19:14
…arch-index

# Conflicts:
#	openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/DataContractResourceIT.java
#	openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataContractRepository.java
The canvas hides the delete control on the last remaining rule, so a
builder can never be emptied. Callers that handle an emptied builder
themselves (the Collate Automator resets to its 'Add Condition' state)
opt in with allowRemoveLastRule; every other builder keeps the default.
…late

A contract has no tags, tier, domains, data products, certification or
service, so conditions on those common fields matched no contract and
reported 0 assets. They are no longer offered while data contracts are
selected, alone or alongside other asset types, the same rule that
limits entity-specific fields to the ones every selected index shares.
…arch-index

# Conflicts:
#	openmetadata-ui/src/main/resources/ui/src/utils/AdvancedSearchClassBase.test.ts
#	openmetadata-ui/src/main/resources/ui/src/utils/AdvancedSearchClassBase.ts
@Khairajani
Khairajani marked this pull request as ready for review October 12, 2026 18:35
@github-actions

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 balanced review requested due to automatic review settings October 12, 2026 18:35

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 Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

❌ UI Checkstyle Failed

❌ Bundle Runtime Check

A route chunk loads but one of its chunks still exports undefined: a chunking change broke module initialisation. Run yarn build && yarn bundle:runtime locally.

🔍 ESLint findings in this PR's files — 0 error(s), 4 warning(s)

Errors block the build. Warnings do not yet — they are rules whose backlog is still
being worked down, listed so this PR does not add to it. See docs/ui-code-quality-gate.md.

0 error(s), 4 warning(s) across 2 changed file(s).

Count Rule
2 openmetadata-imports/no-circular-imports
2 openmetadata-imports/no-lower-layer-page-imports
All findings
Location Rule Message
🟡 src/interface/search.interface.ts:15:1 openmetadata-imports/no-circular-imports This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency.
🟡 src/interface/search.interface.ts:69:1 openmetadata-imports/no-lower-layer-page-imports Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here.
🟡 src/interface/search.interface.ts:70:1 openmetadata-imports/no-circular-imports This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency.
🟡 src/utils/SearchClassBase.ts:62:1 openmetadata-imports/no-lower-layer-page-imports Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here.

Fix locally (fast - only checks files changed in this branch):

make ui-checkstyle-changed

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 77%
77.42% (125043/161499) 63.89% (78319/122565) 65.16% (26110/40070)

Copilot AI balanced review requested due to automatic review settings October 13, 2026 06:27

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.

@Khairajani
Khairajani enabled auto-merge October 13, 2026 12:11
Copilot AI balanced review requested due to automatic review settings October 14, 2026 04:56

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 Oct 14, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · The new Data Contract search index and result-triggered reindexing could make contracts missing or incorrectly filtered if mappings or updates diverge.

Adds a search index for data contracts, enabling governance automations to filter and bulk-update contracts through ES/OpenSearch queries. The index excludes large blocks to avoid mapping explosion, fixes a bug in DataContractRepository.updateLatestResult that was blanking owners and reviewers during reindexing, and includes comprehensive unit and integration test coverage. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

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

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

@Khairajani
Khairajani disabled auto-merge October 14, 2026 11:13
@Khairajani
Khairajani enabled auto-merge October 14, 2026 11:13
@Khairajani
Khairajani added this pull request to the merge queue Oct 14, 2026
Merged via the queue into main with commit 5377edd Oct 15, 2026
85 of 87 checks passed
@Khairajani
Khairajani deleted the feat/data-contract-search-index branch October 15, 2026 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants