-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
Fix bug in NestedUtils.partitionByChildren() #97970
Conversation
Pinging @elastic/es-search (Team:Search) |
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.
Thanks, I left a comment to further simplify the new FieldFetcherTest and maybe add assertions on the whole output there now that its smaller.
var results = fetchFields(mapperService, source, fieldAndFormatList("*", null, false)); | ||
SearchHit searchHit = new SearchHit(0); | ||
searchHit.addDocumentFields(results, Map.of()); | ||
assertThat(Strings.toString(searchHit), containsString("\"ml.top_classes\":")); |
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 think this boils it down even further to make the test more succinct. At least this fails without your above changes and passes otherwise:
MapperService mapperService = createMapperService("""
{ "_doc" : { "properties": {
"ml": {
"properties": {
"feature_importance": {
"type": "nested",
"dynamic": "false",
"properties": {
"feature_name": {
"type": "keyword"
}
}
},
"is_training": {
"type": "boolean"
},
"prediction_probability": {
"type": "double"
},
"top_classes": {
"type": "nested",
"properties": {
"class_name": {
"type": "keyword"
}
}
}
}
}
}}}
""");
String source = """
{
"ml": {
"y_prediction": "no",
"top_classes": [
{
"class_name": "no"
},
{
"class_name": "yes"
}
],
"prediction_probability": 0.978734716971892,
"is_training": false
}
}
""";
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.
Maybe if that version is working for you, could you also change the test slightly so we don't just asset on the substring but actually check the whole output map? Shouldn't be too deep any more now and makes the assertion.
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 think it's important to have more than one entry before and between the nested mappers, to cover all the cases properly? So yes, the cut down version will cover the specific bug here but I'd like to keep more in there to catch regressions.
💔 Backport failed
You can use sqren/backport to manually backport by running |
If multiple fields appeared between two child scopes, the following children would be incorrectly assigned to the parent scope.
If multiple fields appeared between two child scopes, the following children would be incorrectly assigned to the parent scope.
If multiple fields appeared between two child scopes, the following children
would be incorrectly assigned to the parent scope.