-
Notifications
You must be signed in to change notification settings - Fork 25.6k
WIP: Add parsing single bucket #24386
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
WIP: Add parsing single bucket #24386
Conversation
439e146 to
24c6391
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.
this class is not needed anymore as Aggregations is no longer abstract and also implements ToXContent
javanna
left a comment
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.
the parsing itself LGTM,so happy we can add parsing for 5 or 6 aggs at the same time that easily. I think the only point left for discussion is what we want to do with #24020. I left a comment on that also.
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 the problem here is that you have to choose between the match all parser and ignoreUnknownFields ? We need both at the same time right?
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.
Yes, I will think about this again in the context of #24020 which should go in first.
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.
norelease?
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.
Now that all subclasses are actually converted in one PR this can go completely.
24c6391 to
0f2f548
Compare
When parsing aggregations and sun-aggregations we encounter cases where the aggregation name is written to the response as key for a new nested aggregation object on the same level that we want to parse other fields. Currently we cannot use ObjectParser in this situations because it requires some ParseField for matching the field name. This adds a new `declareUnknownFieldParser()` method to ObjectParser that can be used to declare one specific ContextParser that gets called if no other FieldParsers that have been declared match.
0f2f548 to
8fe9637
Compare
| */ | ||
| private final boolean ignoreUnknownFields; | ||
|
|
||
| /** |
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.
nit: typo in matchFieldPrecidate
| public abstract class ParsedSingleBucketAggregation extends ParsedAggregation implements SingleBucketAggregation { | ||
|
|
||
| private long docCount; | ||
| protected List<Aggregation> aggregationList = new ArrayList<>(); |
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.
final?
|
|
||
| private long docCount; | ||
| protected List<Aggregation> aggregationList = new ArrayList<>(); | ||
| private Aggregations aggregations = new Aggregations(aggregationList); |
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.
also final?
| * test parsing fields with a random name | ||
| */ | ||
| public void testUnknownFieldParser() throws IOException { | ||
| XContentBuilder b = XContentBuilder.builder(XContentType.JSON.xContent()); |
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 guess the XContentType could be randomized?
This is a WIP PR for adding parsing to all implementations of SingleBucketAggregation. They are mostly similar internally, so I did them all in one PR because the changes in the individual parsed aggregation implementations are minimal and they also share common testing infrastruture.
Since this requires parsing of inner aggregations that are not rendered inside their own json object structure I had to base this on #24219 which is open and it is not sure if we are going to use it in the current form, so I leave this PR as work in progress for discussion. It shows that the approach taken in #24219 solves the parsing problem at least for the single bucket aggs. There are a few minor TODOs in the code around extending testing and randomization but I leave them for later when we know which way we are taking.