-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Do not allow inner hits that fetch _source and have a non nested object field as parent #25749
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
Do not allow inner hits that fetch _source and have a non nested object field as parent #25749
Conversation
I think it could break quite a number of users? I'm wondering whether we should do the check at search time instead only in the case that the field is mapped as an object and is stored in the source as an array? |
f25bf42
to
ece0e47
Compare
@jpountz I moved the check to fetch phase. This basically means that we throw |
ece0e47
to
7cf26f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a question about the validation.
throw new IllegalArgumentException("Cannot execute inner hits. One or more parent object fields of nested field [" + | ||
nestedObjectMapper.name() + "] are not nested. All parent fields need to be nested fields too"); | ||
} | ||
sourceAsMap = (Map<String, Object>) nestedParsedSource.get(nested.getOffset()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are only checking the first one, but I think we need to iterate over entries from 0 to nested.getOffset() ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the parent object is not nested then XContentMapValues.extractValue(...)
extracts the values from two or more layers resulting in a list of list being returned, because there is one nested level, but in the _source there are two ore more levels. This is why I think only the first element of nestedParsedSource needs to be checked. Checking upto nested.getOffset()
will likely cause an AOBE.
I'll add a comment explaining that.
7cf26f4
to
20ba983
Compare
…ested object field as parent Closes elastic#25315
a better error message instead of an AOBE and not adding more restrictions.
20ba983
to
6c46a67
Compare
The nested source fetch logic can't properly select the part of the source that belongs to a specific nested document if a nested object field's parent object field is non nested.
PR for #25315