Fix issue with extended_stats aggregation on datetime field #4103
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes an issue where a datetime extended_stats aggregation was getting deserialized as a regular stats aggregation.
Running extended_stats on a datetime field (vs a numeric field) returns a different response with extra "as_string" fields.
e.g.
The aggregate json converter was intended to grab the first set of fields, skip the "as_string" metrics, and then, if any more fields remained, to grab the rest of the fields for extended metrics.
However, the existing code was not going back to the json reader when checking to see if the current field was an "as_string" field. Therefore it thought that all of the remaining fields were "as_string" fields, even though that was not the case.