Skip to content

Comments

Add mappings for enrich fields (#96056)#10

Open
MitchLewis930 wants to merge 1 commit intopr_020_beforefrom
pr_020_after
Open

Add mappings for enrich fields (#96056)#10
MitchLewis930 wants to merge 1 commit intopr_020_beforefrom
pr_020_after

Conversation

@MitchLewis930
Copy link

@MitchLewis930 MitchLewis930 commented Jan 30, 2026

PR_020


Note

Medium Risk
Changes how enrich index mappings are generated/validated and can alter field capabilities (indexing/doc_values) for downstream enrich lookups. Risk is moderated by extensive test updates and added conflict-coverage, but it touches core ingest/enrich behavior.

Overview
Enrich policy execution now creates enrich indices with explicit mappings for all configured enrich_fields, not just the match field. Non-match enrich fields are copied from source mappings (including format where applicable), marked index: false, and the match field mapping logic is refactored to validate consistent types/formats across all source indices (preserving range/date_range formats and enabling doc values when the match field is also an enrich field).

Tests are updated to assert the expanded mappings and add coverage for cross-index conflicts where enrich fields have incompatible types or formats (these fields are omitted from the enrich index mapping rather than failing policy execution unless the conflict is on the required match field).

Written by Cursor Bugbot for commit 00afc5b. This will update automatically on new commits. Configure here.

We are developing a new component that performs lookup during query 
time. The idea is to utilize the existing enrich policies and indices 
used during indexing. However, to ensure proper functionality of the new
component, we need the mapping types and doc_values of the enrich
fields.

With this change, populating the mapping for enrich fields is a 
best-effort process to maintain the current behavior. This means that
any mapping conflicts arising between the enrich fields of the source
indices will be ignored. I will follow up to address this validation
issue.
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

if (strictlyRequired) {
throw new ElasticsearchException(
"Multiple distinct formats specified for field '{}' - indices({}) format entries({})",
policy.getMatchField(),
Copy link

Choose a reason for hiding this comment

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

Wrong field name used in format error message

Low Severity

The error message for multiple distinct formats uses policy.getMatchField() instead of fieldName. The method takes fieldName as a parameter and correctly uses it in the similar error for multiple types at line 217. Using the wrong variable causes the exception message to report an incorrect field name when a non-match field has conflicting formats.

Fix in Cursor Fix in Web

}
if (formatEntries.isEmpty()) {
// no format specify rely on default
return createEnrichMappingBuilder((builder) -> builder.field("type", type).field("doc_values", false));
Copy link

Choose a reason for hiding this comment

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

Unreachable null check is dead code

Low Severity

The if (currentField == null) check at line 300 is dead code. The for loop above (lines 257-299) is guaranteed to execute at least once since fieldName is asserted non-empty at line 252. Inside the loop, if currentField becomes null (line 280), the method either throws an exception or returns null (lines 281-291). Therefore, after the loop completes normally, currentField is always non-null, making this check unreachable.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants