Skip to content

Tweak copy_to handling in synthetic _source to account for nested objects#120974

Merged
lkts merged 6 commits intoelastic:mainfrom
lkts:fix_copy_to_synthetic_source
Jan 28, 2025
Merged

Tweak copy_to handling in synthetic _source to account for nested objects#120974
lkts merged 6 commits intoelastic:mainfrom
lkts:fix_copy_to_synthetic_source

Conversation

@lkts
Copy link
Contributor

@lkts lkts commented Jan 27, 2025

Closes #120831.

@lkts lkts added >bug auto-backport Automatically create backport pull requests when merged :StorageEngine/Mapping The storage related side of mappings v8.18.0 labels Jan 27, 2025
@lkts lkts requested review from kkrik-es and martijnvg January 27, 2025 23:08
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

@elasticsearchmachine
Copy link
Collaborator

Hi @lkts, I've created a changelog YAML for you.

continue;
}
int offset = parent.isRoot() ? 0 : parent.fullPath().length() + 1;
mutableList.add(new IgnoredSourceFieldMapper.NameValue(copyToField, offset, XContentDataHelper.voidValue(), context.doc()));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is this call to context.doc(). This is a root document and not a correct nested document.

int offset = parent.isRoot() ? 0 : parent.fullPath().length() + 1;
ignoredFieldValues.add(new IgnoredSourceFieldMapper.NameValue(copyToField, offset, XContentDataHelper.voidValue(), doc));
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think getCopyToFields is not called any more? If so, remove it - and maybe inline markFieldAsCopyTo here and remove it.

Copy link
Member

Choose a reason for hiding this comment

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

Not related to this change, but also cloneWithRecordedSource(...) is not used.

Copy link
Contributor Author

@lkts lkts Jan 28, 2025

Choose a reason for hiding this comment

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

markFieldAsCopyTo is done after parsing and this is done before and i don't know if this is important. I won't experiment.

Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

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

LGTM

int offset = parent.isRoot() ? 0 : parent.fullPath().length() + 1;
ignoredFieldValues.add(new IgnoredSourceFieldMapper.NameValue(copyToField, offset, XContentDataHelper.voidValue(), doc));
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Not related to this change, but also cloneWithRecordedSource(...) is not used.

@lkts lkts merged commit 8d057d8 into elastic:main Jan 28, 2025
16 checks passed
@lkts lkts deleted the fix_copy_to_synthetic_source branch January 28, 2025 20:42
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
8.x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged >bug :StorageEngine/Mapping The storage related side of mappings Team:StorageEngine v8.18.0 v9.0.0

4 participants