-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Fix counted_keyword support in arrays of objects #121558
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 counted_keyword support in arrays of objects #121558
Conversation
|
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
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.
LGTM and i think this is backwards compatible as well since doc values have the same format. @martijnvg do you see any problems with BWC here?
Yes, I think this change doesn't break bwc. Since keep storing the values as single binary array (even though the values may have come from multiple array elements or leaf fields with the same name), so the format doesn't change. |
| @Override | ||
| public BytesRef binaryValue() { | ||
| try { | ||
| int bytesSize = (counts.size() + 1) * 5; |
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 use a constant with a meaningful name for 5?
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
As a result of the randomized testing enabled in #121462, we found that we currently fail to parse documents with arrays of objects containing counted_keyword fields. This PR fixes this issue by using a custom docvalues field to store the count instead of the built-in lucene BinaryDocValues. This custom CountsBinaryDocValuesField has logic to handle multiple values for the same field. (cherry picked from commit 13b743c)
As a result of the randomized testing enabled in #121462, we found that we currently fail to parse documents with arrays of objects containing counted_keyword fields.
For example, attempting to index this document with this mapping would produce an error:
Mapping:
Document:
{ "parent": [ {"child": "a"}, {"child": "b"} ] }Error:
"type":"illegal_argument_exception","reason":"DocValuesField \"parent.child_count\" appears more than once in this document (only one value is allowed per field)This PR fixes this issue by using a custom docvalues field to store the count instead of the built-in lucene
BinaryDocValues. This customCountsBinaryDocValuesFieldhas logic to handle multiple values for the same field.