Skip to content

Fix Elasticsearch/OpenSearch field explosion with custom properties - #25627

Merged
mohityadav766 merged 23 commits into
mainfrom
fix-os-limits-issue
Feb 5, 2026
Merged

mohityadav766 merged 23 commits into
mainfrom
fix-os-limits-issue

Conversation

@mohityadav766

@mohityadav766 mohityadav766 commented Jan 29, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Fixes field explosion issue when many custom properties are created by implementing flattened extension fields and typed custom properties.

What changed:

  • Changed extension field from object to flattened type across all Elasticsearch mappings (145+ files)
  • Added customPropertiesTyped nested field with structured subfields for efficient querying:
    • stringValue/textValue for string properties
    • longValue/doubleValue for numeric properties
    • start/end for time interval properties
    • refId/refName/refFqn/refType for entity reference properties
  • Implemented OpenSearch compatibility by transforming flattened → flat_object at runtime
  • Enhanced query builder to intelligently route custom property queries to appropriate typed fields
  • Added column extension transformation for entities with columns (Table, Container, DashboardDataModel, Worksheet)
  • Added dynamic: false to prevent field explosion in lifeCycle, votes, and other objects

Why:

  • Prevents Elasticsearch/OpenSearch from hitting field count limits (default 1000) when many custom properties are created
  • Maintains search functionality while keeping field counts bounded
  • Enables efficient range queries on numeric custom properties

Testing:

  • Added SearchIndexFieldLimitIT.java integration test verifying field counts stay bounded with many custom properties
  • Tested with multiple database and search engine combinations (MySQL+Elasticsearch, PostgreSQL+OpenSearch)

Type of change:

  • Bug fix
  • Improvement

@mohityadav766

Copy link
Copy Markdown
Member Author

@gitar-bot can you review this PR

@gitar-bot

gitar-bot Bot commented Jan 29, 2026

Copy link
Copy Markdown

@gitar-bot can you review this PR

I'll review this PR for you. The code review is being performed and results will be posted shortly.

@github-actions

github-actions Bot commented Jan 29, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 65%
65.83% (55873/84881) 44.89% (28849/64271) 47.91% (8811/18389)

@sonarqubecloud

sonarqubecloud Bot commented Feb 4, 2026

Copy link
Copy Markdown

@gitar-bot

gitar-bot Bot commented Feb 5, 2026 •

Copy link
Copy Markdown
🔍 CI failure analysis for 2667201: Maven PostgreSQL CI has 3 AWS credential test errors (unrelated infrastructure issue). The 9 custom property persistence/search test failures from Playwright continue - all PR-related and critical.

Issue

Multiple CI jobs failing: maven-postgresql-ci (3 test errors), Test Report (aggregation failure), and continuing Playwright E2E failures.

Root Cause

A. Maven PostgreSQL CI - Unrelated Infrastructure Failure

3 test errors in AwsCredentialsUtilTest - all throwing IllegalArgumentException:

  1. testBuildCredentialsProviderWithOnlyAccessKey
  2. testBuildCredentialsProviderWithNoCredentials
  3. testBuildCredentialsProviderWithEmptyCredentials

Error: AWS credentials not configured. Either provide accessKeyId/secretAccessKey or set enabled=true to use IAM authentication

Why Unrelated: No AWS-related files modified in this PR. This is an infrastructure/environment configuration issue unrelated to custom property indexing changes.

B. Custom Properties - CRITICAL PR-Related Failures (Ongoing) ⚠️

9 flaky custom property tests across Playwright shards 3/6 and 4/6 remain failing - all directly related to this PR's indexing changes.

Critical Pattern: Custom properties save initially but fail to persist/retrieve after page reload.

Affected Types: Sql Query, Hyperlink, Entity Reference, Entity Reference List (HTTP 500), Date, DateTime, String, Duration, plus Advanced Search timeout

Impact:

  • Data persistence broken across all major custom property types
  • Advanced search with custom properties timing out
  • Backend HTTP 500 error on Entity Reference List
  • Multiple entity types affected (tableColumn, container, pipeline)

C. Test Report Job

Failed due to aggregating maven-postgresql-ci test failures. No independent failure.

D. Unrelated Ongoing Failures

  • MUITagSuggestion tests (9 tests) - From recent main merge, incorrect assertions
  • Various Playwright infrastructure flakiness - Permissions, widgets, alerts

Details

Maven Test Results: 7914 tests run, 3 errors (AwsCredentialsUtilTest), 701 skipped

Root Cause for Custom Property Failures: New flattened extension + customPropertiesTyped structure has issues with data transformation when writing to ES/OS and retrieval from new nested structure.

Code Review 👍 Approved with suggestions 3 resolved / 5 findings

Solid implementation for fixing Elasticsearch field explosion. The approach using flattened type and typed nested properties is well-designed. Two minor suggestions around query building edge cases and test reliability.

💡 Edge Case: not_between operator builds query with wrong range structure

📄 openmetadata-ui/src/main/resources/ui/src/utils/QueryBuilderElasticsearchFormatUtils.js:357-358

In buildNestedTypedQuery, when operator === 'between', the code correctly uses gte and lte with value[0] and value[1]. However, there's no explicit handling for not_between in the range query building section. The function checks isRangeOperator(operator) which includes not_between, but then the if (operator === 'between') branch won't match, and not_between falls through to no range query being built at all.

The not_between negation is applied later at line 660, but by that point mainQuery may not have been built correctly since not_between doesn't match the between case.

Suggested fix: Add explicit handling for not_between in the range operator section:

if (operator === 'between' || operator === 'not_between') {
  if (Array.isArray(value) && value.length >= 2) {
    rangeQuery.gte = value[0];
    rangeQuery.lte = value[1];
  }
}

This ensures the range query is built correctly before negation is applied.

💡 Quality: Fixed Thread.sleep(2000) in tests may cause flaky behavior

📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/SearchIndexFieldLimitIT.java:255 📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/SearchIndexFieldLimitIT.java:294 📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/SearchIndexFieldLimitIT.java:359

The integration tests use Thread.sleep(2000) to wait for Elasticsearch indexing to complete. This is a code smell that can lead to flaky tests - the sleep may be too short under load or unnecessarily long in normal conditions.

Impact: Tests may fail intermittently if indexing takes longer than 2 seconds, or CI runs will be slower than necessary.

Suggested fix: Consider implementing a polling mechanism that waits for the document to be indexed:

private void waitForIndexing(RestClient searchClient, String indexName, String documentId, int maxRetries) throws Exception {
    for (int i = 0; i < maxRetries; i++) {
        // Check if document exists in index
        Request request = new Request("GET", "/" + indexName + "/_doc/" + documentId);
        try {
            searchClient.performRequest(request);
            return; // Document found
        } catch (ResponseException e) {
            if (e.getResponse().getStatusLine().getStatusCode() == 404) {
                Thread.sleep(500); // Brief wait before retry
            } else {
                throw e;
            }
        }
    }
    throw new AssertionError("Document not indexed within timeout");
}

This would make tests more reliable while potentially being faster.

✅ 3 resolved
✅ Edge Case: Colons in property values break search key:value format

📄 openmetadata-service/src/main/java/org/openmetadata/service/search/SearchIndexUtils.java:40
The flattenCustomProperties method creates key:value pairs using a simple colon separator (key + ":" + valueStr). If a custom property value contains a colon (e.g., {"url": "https://example.com"}), the stored value url:https://example.com becomes ambiguous and could cause incorrect query matches when searching.

Impact: Searching for custom properties with colons in values may produce unexpected results.

Suggested fix: Consider using a delimiter that's less common in values, or escape colons within values:

String escapedValueStr = valueStr.replace(":", "\\:");
String pair = key + ":" + escapedValueStr;

Or document this limitation for users.

✅ Edge Case: Null check missing after JsonUtils.getMap() call

📄 openmetadata-service/src/main/java/org/openmetadata/service/search/SearchIndexUtils.java:35
The flattenCustomProperties method calls JsonUtils.getMap(extension) without checking if the returned map is null. If getMap() returns null for certain extension objects (e.g., invalid JSON, empty object), iterating over extensionMap.entrySet() will throw a NullPointerException.

Impact: Could cause search indexing to fail for entities with certain extension data.

Suggested fix:

Map<String, Object> extensionMap = JsonUtils.getMap(extension);
if (extensionMap != null) {
  for (Map.Entry<String, Object> entry : extensionMap.entrySet()) {
    // ... existing logic
  }
}
✅ Quality: Extension query bypasses with undefined value at index 0

📄 openmetadata-ui/src/main/resources/ui/src/utils/QueryBuilderElasticsearchFormatUtils.js:327
The buildExtensionQuery function is called conditionally with value[0] !== undefined, but this allows falsy values like empty strings or 0 to pass through. This is intentional for numeric queries, but if value itself is undefined or not an array, accessing value[0] could fail silently or behave unexpectedly.

Additionally, the condition isNestedExtensionField && entityType && value && value[0] !== undefined may prevent legitimate queries where the value is explicitly 0 or an empty string.

Suggested fix: Make the condition more explicit:

if (isNestedExtensionField && entityType && Array.isArray(value) && value.length > 0) {

Tip

Comment Gitar fix CI or enable auto-apply: gitar auto-apply:on

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqubecloud

sonarqubecloud Bot commented Feb 5, 2026

Copy link
Copy Markdown

This branch was previously deployed

1 inactive deployment
test — 26672010 Deployed Feb 5, 2026 by mohityadav766 via playwright-ci-postgresql (2, 6) #33076
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants