Skip to content

feat(okf): make OKF frontmatter extensions searchable and filterable - #21886

Open
shirshanka wants to merge 3 commits into
masterfrom
okf-searchable-extensions
Open

shirshanka wants to merge 3 commits into
masterfrom
okf-searchable-extensions

Conversation

@shirshanka

@shirshanka shirshanka commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

What

An OKF document can now be found by its custom frontmatter keys. A concept with x-domain: finance (OKF 0.3) or domain: finance (earlier bundles) matches the filter okfExtensions = x-domain=finance (or domain=finance) on Search V2 and V3, and its extension values are matched by full-text search.

Until now, keys with no typed field lived only in okfProperties.raw, which isn't indexed, so nobody could search or filter on them.

The field: okfProperties.extensions

A new extensions: optional map[string, string] on okfProperties, indexed as okfExtensions.

  • Name: OKF calls producer-defined keys extensions, and the source docs already use that word ("the optional producer extension id", "version keys remain extensions"). customProperties would be confused with the native aspect of that name.
  • What goes in: every frontmatter key that no field or aspect maps, keyed as written, x- prefix included. Mapped keys (id, type, title, description, status, stale_after, generated, verified, owners, tags, glossary_terms) and the accepted OKF 0.3 aliases x-datahub-id, x-datahub-owners and x-datahub-glossary_terms are left out.
  • Scalars: stored as text; booleans and numbers in their JSON form (true, 2, 0.5). Dates are already strings.
  • Lists of scalars: joined with , ([analysts, engineers] → analysts, engineers). A map<string,string> holds one value per key. A MAP_ARRAY field would allow one value per list item, but it's indexed as an object (okfExtensions.<key>), not as key=value, so it wouldn't filter like customProperties. With joining, a filter matches only the whole list, while full-text search still finds each item.
  • Nested objects: flattened into dotted keys, up to three levels: x-team: {lead: alice} → x-team.lead = alice. OKF 0.3 allows nested custom values, and flattening keeps them filterable. Deeper levels are left out. If a flattened key matches a key written with dots, the first one in the file is kept and the other is reported.
  • Left out silently (they stay in raw and frontmatter): nulls, empty and blank values (empty counts as absent, including blank list items), and lists that contain objects, lists or nulls.
  • Caps: at most 50 entries per concept, in frontmatter order. Keys are up to 100 characters and can't contain =, since search stores key=value. Values are up to 1,000 characters, well under GMS's 4,096-character SEARCH_DOCUMENT_MAX_VALUE_LENGTH, which would otherwise drop longer values from the index without a word. Each file that goes over a cap, or nests too deeply, gets one warning listing the keys, and the count adds to okf_extensions_dropped in the report.
  • x-datahub-*: x-datahub-id, x-datahub-owners and x-datahub-glossary_terms are excluded because they're OKF 0.3 spellings of mapped keys. The mapping itself comes in feat(ingest/repository-documents): import OKF bundles by the OKF 0.3 rules #21885. Merge this PR after feat(ingest/repository-documents): import OKF bundles by the OKF 0.3 rules #21885 or together with it: on its own, this PR leaves those keys out of both the mapping and extensions.
  • raw stays the only source of truth. extensions is derived from it at import, like the other typed fields.

Search

The annotation copies customProperties: "/*" map, fieldType: TEXT.

  • V2: each entry is indexed as key=value (keyword plus .delimited) and queried by default, like customProperties.
  • V3: queryByDefault: false and copyToOther: true, like customProperties. Values reach full text through the shared other field and stay out of the per-field query list, so the search template golden (field-manifest.json) doesn't change.
  • Filters: EQUAL on okfExtensions with x-domain=finance is exact. IEQUAL ignores case. START_WITH with x-domain= finds documents that declare the key.

okfProperties schemaVersion goes to 3, as #21877 did for the description. With unknown-data tolerance on, a rolled-back GMS uses the version stamp to treat rows that carry extensions as the newer version's. GraphQL exposes OkfProperties.extensions: [StringMapEntry!].

The ingestion MAPPING_VERSION goes to 7. It feeds the source hash, so the next import rewrites concepts whose files haven't changed and fills extensions without a forced re-run.

Upgrade

The new field is added to the existing mappings, so no reindex is needed. Documents imported before this change have no extensions until they're imported again. Rerun the OKF ingestion recipe once; the mapping-version bump makes it rewrite every concept. RestoreIndices doesn't help here, because the stored aspects have no extensions until re-import.

Example

searchAcrossEntities(input: {
  types: [DOCUMENT], query: "*",
  orFilters: [{ and: [{ field: "okfExtensions", values: ["x-domain=finance"] }] }]
})

The agent filter alias okf.domain = finance (stacked PRs below) sends IEQUAL ["domain=finance", "x-domain=finance"] on this field.

Tests

  • test_okf_metadata.py: scalars, lists, flattening and the depth cap, skipped values, mapped keys and x-datahub-* aliases left out, the count, length and = caps with one warning.
  • test_github_documents_source.py and the GitHub and GitLab documents integration goldens: extensions on the imported concept, mapping version 7.
  • SearchDocumentTransformerTest: extensions is indexed as okfExtensions key=value entries.
  • SearchQueryBuilderTest: V2 default query fields include okfExtensions and okfExtensions.delimited.
  • V3SearchFieldsTest: okfExtensions is among the document's V3 other full-text sources.
  • DocumentMapperTest: GraphQL maps extensions, and leaves it null when unset.
  • Smoke test test_okf_extensions_are_filterable: writes a concept with x-domain, a joined list and a flattened nested key. It finds the concept by EQUAL on each one, by IEQUAL on both spellings with different case, and by START_WITH x-domain=. It also finds it by full text on an extension value, and checks that a wrong value and an undeclared key don't match.

How I tested it locally:

  • :metadata-io:test filtered to SearchTemplateGoldenTest, V3SearchFieldModelTest, V3SearchFieldsTest, SearchQueryBuilderTest, SearchDocumentTransformerTest, MultiEntityMappingsBuilderTest and V2MappingsBuilderTest, plus :datahub-graphql-core:test DocumentMapperTest: all pass. The golden is unchanged.
  • :metadata-ingestion:testSingle on the repository, GitHub and GitLab documents unit and integration tests: 330 pass. :metadata-ingestion:lint is clean for these files.
  • Docker-free stack (scripts/dev/datahub-dev.sh start --local --job smoke-test): test_okf_search.py passes on Search V3. With the V2 index on and V3 keyword reads off, the new extensions test passes too. The live V2 mapping has okfExtensions as keyword with .delimited.

Related

Checklist

  • PR title follows the Contributing Guideline
  • Tests added/updated

🤖 Opened with cclaude on behalf of @shirshanka

@cclaude-datahub-project cclaude-datahub-project Bot added the cclaude Opened from a cclaude box label Dec 4, 2026
@github-actions github-actions Bot added ingestion PR or Issue related to the ingestion of metadata product PR or Issue related to the DataHub UI/UX smoke_test Contains changes related to smoke tests labels Dec 4, 2026
@cursor

cursor Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

PR Summary

Overview
OKF concepts can now expose producer extension frontmatter keys (anything not mapped to native or typed OKF fields) via a new okfProperties.extensions string map, derived at import and mirrored in GraphQL as okfProperties.extensions.

Ingestion parse_extensions flattens nested objects (up to three levels), joins scalar lists with ", ", skips reserved/mapped keys (including x-datahub-* aliases), and enforces caps with okf_extensions_dropped warnings; MAPPING_VERSION is 7 so unchanged files re-import and populate the field. OkfProperties aspect schemaVersion is 3.

Search indexes each entry as key=value on okfExtensions (V2 default query + filters like customProperties; V3 full-text via other). Docs and tests cover EQUAL / IEQUAL / START_WITH filtering and golden/MCES updates.

Reviewed by Cursor Bugbot for commit 46dfdfa. Bugbot is set up for automated code reviews on this repo. Configure here.

@codecov

codecov Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.38710% with 1 line in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...estion/source/repository_documents/okf_metadata.py 98.18% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Smart test selection

pytest smoke tests

Mode: active. Only the selection below runs for the pytest smoke tests on this PR (applied: smart).

  • Selection: smart: tests for the tagged features, plus always-run modules, this PR's changed tests, and the plumbing sample if the PR changes the pytest harness
  • Size: 205 of 861 tests in 1 batch, predicted longest batch ~4 min
  • Tags: change-type: docs; feature-dev: entity-registry, search-indexing; feature-user: documentation, search; technical-layer: elasticsearch, graphql
  • Confidence: HIGH (17 changed files)
  • Classifier reasoning: OKF document frontmatter extensions are mapped into okfProperties and GraphQL and indexed for search, with a PDL schema bump, ingestion mapping changes, and related tests and docs.
Selected scopes (45 files or classes, 205 tests)
  • tests/e2e/actions/doc_propagation/test_propagation.py
  • tests/e2e/authorization/test_self_entity_auth.py
  • tests/e2e/browse/browse_test.py
  • tests/e2e/cli/migrate_cmd/test_migrate_instance2instance_smoke.py
  • tests/e2e/cli/migrate_cmd/test_migrate_scenarios_smoke.py
  • tests/e2e/cli/search_cmd/test_search_cmd.py::TestSearchBasic
  • tests/e2e/cli/search_cmd/test_search_cmd.py::TestSearchDiagnose
  • tests/e2e/cli/search_cmd/test_search_cmd.py::TestSearchDryRun
  • tests/e2e/cli/search_cmd/test_search_cmd.py::TestSearchErrorHandling
  • tests/e2e/cli/search_cmd/test_search_cmd.py::TestSearchFilterCombinations
  • tests/e2e/cli/search_cmd/test_search_cmd.py::TestSearchFiltersByEntityType
  • tests/e2e/cli/search_cmd/test_search_cmd.py::TestSearchFiltersByPlatform
  • tests/e2e/cli/search_cmd/test_search_cmd.py::TestSearchPagination
  • tests/e2e/cli/search_cmd/test_search_cmd.py::TestSearchProjectionLive
  • tests/e2e/cli/search_cmd/test_search_cmd.py::TestSearchWhereFilter
  • tests/e2e/delete/delete_assertion_cascade_test.py
  • tests/e2e/frontend/test_static_asset_encodings.py
  • tests/e2e/institutional_memory/institutional_memory_test.py
  • tests/e2e/knowledge/document_change_history_test.py
  • tests/e2e/knowledge/document_search_filter_test.py
  • tests/e2e/knowledge/test_document_crud.py::TestDocumentCrudAndMutations
  • tests/e2e/knowledge/test_document_hierarchy_settings.py::TestDocumentHierarchyAndSettings
  • tests/e2e/knowledge/test_document_search_history.py::TestDocumentSearchAndHistory
  • tests/e2e/knowledge/test_okf_reimport.py
  • tests/e2e/knowledge/test_okf_search.py
  • tests/e2e/managed_ingestion/ingestion_source_run_events_test.py
  • tests/e2e/mcp/mcp_test.py
  • tests/e2e/query_projection/test_query_projection_smoke.py
  • tests/e2e/read_only/test_search.py
  • tests/e2e/read_only/test_services_up.py
  • tests/e2e/restli/restli_test.py
  • tests/e2e/restli/test_restli_batch_ingestion.py
  • tests/e2e/search/test_lineage_search_index_fields.py
  • tests/e2e/search/test_search_projection.py::TestSearchProjection
  • tests/e2e/semantic/test_classical_embedding_provider.py::TestClassicalEmbeddingProvider
  • tests/e2e/semantic/test_config_fingerprint.py::TestConfigFingerprint
  • tests/e2e/semantic/test_current_offset_api.py
  • tests/e2e/semantic/test_event_driven_docs.py::TestEventDrivenDocumentIngestion
  • tests/e2e/semantic/test_event_mode_fallback.py::TestEventModeFallback
  • tests/e2e/semantic/test_local_embedding_provider.py::TestLocalEmbeddingProvider
  • tests/e2e/semantic/test_semantic_search.py::TestSemanticSearchWithIngestion
  • tests/e2e/semantic/test_source_type_filtering.py::TestSourceTypeFiltering
  • tests/e2e/semantic/test_stateful_ingestion.py::TestStatefulIngestion
  • tests/e2e/siblings/siblings_search_batching_test.py
  • tests/e2e/test_e2e.py

Add the run-all-tests:pytest label to run the full pytest suite on this PR.

Playwright E2E tests

This run: smart

  • Selection: smart: specs tagged documentation, entity-registry, search, search-indexing plus the tests the change affects
  • Size: 87 tests in 18 spec files, ~19 min predicted on 3 shard(s)
Specs selected because of this PR (18)
Spec Tests Why
autocomplete-v2/autocomplete.spec.ts 2/2 tagged search
browse-v2/browse-v2.spec.ts 10/10 tagged search
documents/document-import.spec.ts 3/3 tagged documentation
documents/document-management.spec.ts 11/11 tagged documentation
documents/document-tree-expand.spec.ts 2/2 tagged documentation
documents/external-document-profile.spec.ts 1/1 tagged documentation
entity-pages/summary-tab/v2-dataset-summary-about-section.spec.ts 2/2 tagged documentation
entity-pages/summary-tab/v2-summary-tab-about-section.spec.ts 2/2 tagged documentation
logical-models/physical-children-view.spec.ts 2/2 tagged search
mutations-v2/v2-edit-documentation.spec.ts 7/7 tagged documentation
mutations/edit-documentation.spec.ts 1/1 tagged documentation
schema-scale/schema-scale.spec.ts 2/2 tagged documentation
search/query-and-filter-search.spec.ts 10/10 tagged search
search/search-filters.spec.ts 5/5 tagged search
search/search-within-operator.spec.ts 1/1 tagged search
search/search.spec.ts 7/7 tagged search
search/searchv2.spec.ts 15/15 tagged search
upload-files/upload-files.spec.ts 4/4 tagged documentation

Add the run-all-tests:playwright label to run the full Playwright suite on this PR.

commit 46dfdfa · workflow run

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

i18n locale parity

Status: ⚠️ drift detected (warn-only) — 135 issue(s) across 13 locale(s)

Locale Missing keys Stale keys Placeholder Files
de 153 10 0 10
es 153 10 0 10
fi 153 12 0 11
fr 153 10 0 10
hu 153 10 0 10
it 153 10 0 10
ja 153 12 0 11
nb 153 10 0 10
pt-BR 153 10 0 10
ru 153 13 0 12
sv 153 10 0 10
zh-CN 153 10 0 10
zh-TW 153 12 0 11

Per-key detail is in the job summary of the datahub-web-react-lint run, or reproduce locally:

./gradlew :datahub-web-react:yarnI18nParityCheck        # all locales
cd datahub-web-react && yarn check-i18n-parity --lang de  # one locale

@cubic-dev-ai cubic-dev-ai Bot 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.

1 issue found and verified against the latest diff

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="metadata-ingestion/src/datahub/ingestion/source/repository_documents/okf_mapping.py">

<violation number="1" location="metadata-ingestion/src/datahub/ingestion/source/repository_documents/okf_mapping.py:66">
P2: These aliases are removed from searchable extensions but never mapped to their canonical fields, so `x-datahub-id`, `x-datahub-owners`, and `x-datahub-glossary_terms` are silently lost from derived metadata. Normalize the aliases before typed mapping or make the typed mapping read both spellings while retaining the exclusion from extensions.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

)
# OKF 0.3 spellings of mapped keys, accepted as aliases.
MAPPED_KEY_ALIASES = frozenset(
{"x-datahub-id", "x-datahub-owners", "x-datahub-glossary_terms"}

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.

P2: These aliases are removed from searchable extensions but never mapped to their canonical fields, so x-datahub-id, x-datahub-owners, and x-datahub-glossary_terms are silently lost from derived metadata. Normalize the aliases before typed mapping or make the typed mapping read both spellings while retaining the exclusion from extensions.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At metadata-ingestion/src/datahub/ingestion/source/repository_documents/okf_mapping.py, line 66:

<comment>These aliases are removed from searchable extensions but never mapped to their canonical fields, so `x-datahub-id`, `x-datahub-owners`, and `x-datahub-glossary_terms` are silently lost from derived metadata. Normalize the aliases before typed mapping or make the typed mapping read both spellings while retaining the exclusion from extensions.</comment>

<file context>
@@ -54,6 +55,17 @@
+)
+# OKF 0.3 spellings of mapped keys, accepted as aliases.
+MAPPED_KEY_ALIASES = frozenset(
+    {"x-datahub-id", "x-datahub-owners", "x-datahub-glossary_terms"}
+)
+MAPPED_KEYS = OKF_PROPERTY_KEYS | frozenset(NATIVE_MAPPINGS) | MAPPED_KEY_ALIASES
</file context>

@cubic-dev-ai cubic-dev-ai Bot 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.

1 existing issue remains and no new issues found across 16 files

Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.

View guided diff | Turn on auto-fix | Re-trigger cubic

@codecov

codecov Bot commented Dec 4, 2026

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@datahub-connector-tests

datahub-connector-tests Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Connector Tests Results

Connector tests failed for commit 46dfdfa

View full test logs →

To skip connector tests, add the skip-connector-tests label (org members only).

Autogenerated by the connector-tests CI pipeline.

This branch was successfully deployed

1 active deployment
Preview — 46dfdfaa Deployed Dec 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cclaude Opened from a cclaude box ingestion PR or Issue related to the ingestion of metadata product PR or Issue related to the DataHub UI/UX smoke_test Contains changes related to smoke tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant