Skip to content

Conversation

@romseygeek
Copy link
Contributor

When a runtime field is defined in mappings, it automatically shadows any
corresponding fields that might be dynamically created. If a document is
added with an object that matches a runtime field, we need to make sure
that all of the object's children are skipped during parsing.

@romseygeek romseygeek requested a review from javanna December 3, 2020 12:26
@romseygeek romseygeek self-assigned this Dec 3, 2020
@romseygeek romseygeek added :Search Foundations/Mapping Index mappings, including merging and defining field types >non-issue v7.11.0 v8.0.0 labels Dec 3, 2020
@elasticmachine elasticmachine added the Team:Search Meta label for search team label Dec 3, 2020
@elasticmachine
Copy link
Collaborator

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

@romseygeek
Copy link
Contributor Author

Marking as a >non-issue because this is an unreleased bug

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.

Good catch, left a couple of comments

return Collections.singleton(new RuntimeFields());
}

public void testRuntimeFieldShadowsObject() throws IOException {
Copy link
Member

Choose a reason for hiding this comment

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

could this test fit into the existing DocumentParserTests? I have added similar tests in there as part of #65210

protected void parseCreateField(ParseContext context) throws IOException {
//field defined as runtime field, don't index anything
//field defined as runtime field, don't index anything but skip over any possible children
context.parser().skipChildren();
Copy link
Member

Choose a reason for hiding this comment

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

I am not 100% sure that this is the expected behaviour. The way they are applied, runtime fields are an additional layer on top of ordinary fields. because an object field is shadowed by a runtime field, we end up skipping all of the children structure and not index fields that would not be directly shadowed. If doable, could we consider instead mapping objects as objects even if they are shadowed? That would be more inline with the statement that "objects cannot be defined in the runtime section".

type: date
location:
type: object
enabled: false
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason why here you haven't applied dynamic: false like in other tests?

@romseygeek
Copy link
Contributor Author

I'm going to close this and open a separate PR to deal with object children, given that the actual solution is sufficiently different from what I have here.

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

Labels

>non-issue :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Meta label for search team v7.11.0 v8.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants