Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested path info shouldn't be added during copy_to #93340

Merged
merged 3 commits into from
Feb 1, 2023

Conversation

romseygeek
Copy link
Contributor

When executing the copy_to mappings on a nested doc, if the location was
underneath another nested mapper then the document parser could end up
adding a new nested path metadata field for the source to the destination
document. This was mostly ignored, but could make calculation of a
NestedIdentity incorrect, leading to exceptions when loading the source of
a nested document during the fetch phase.

This commit moves all of the nested path handling directly into
DocumentParserContext.createNestedContext(), which already has some
logic to detect if we're in a copy_to context.

Fixes #93117

@romseygeek romseygeek added >bug :Search/Search Search-related issues that do not fall into other categories v8.7.0 labels Jan 30, 2023
@romseygeek romseygeek self-assigned this Jan 30, 2023
@elasticsearchmachine elasticsearchmachine added the Team:Search Meta label for search team label Jan 30, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

@elasticsearchmachine
Copy link
Collaborator

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

@romseygeek
Copy link
Contributor Author

@elasticmachine update branch

Copy link
Member

@javanna javanna left a comment

Choose a reason for hiding this comment

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

LGTM, can you double check that the additional tests are enough? Do they cover the scenario that the user reported? it was not obvious to me.

@romseygeek
Copy link
Contributor Author

I did have another test that used the input from the original bug, but after I'd narrowed everything down sufficiently to reproduce with a simple test it turned out that a couple of simple checks on the existing CopyToMapperTests did the same thing. The bug would manifest itself as a nested doc containing multiple _nested_path fields, so checking that each nested field just contains a single instance of this field is sufficient to catch a regression.

@javanna
Copy link
Member

javanna commented Feb 1, 2023

Thanks for clarifying @romseygeek

@romseygeek romseygeek merged commit d62fe29 into elastic:main Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team v8.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IndexOutOfBoundsException fetch innerhits
4 participants