Skip to content

Conversation

@cbuescher
Copy link
Member

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.

Copy link
Member

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

Copy link
Member

@javanna javanna left a 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.

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

norelease?

Copy link
Member Author

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.

@cbuescher cbuescher force-pushed the addParsing-SingleBucket branch from 24c6391 to 0f2f548 Compare May 8, 2017 12:45
cbuescher added 4 commits May 9, 2017 11:14
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.
@cbuescher cbuescher force-pushed the addParsing-SingleBucket branch from 0f2f548 to 8fe9637 Compare May 9, 2017 09:24
*/
private final boolean ignoreUnknownFields;

/**
Copy link
Member

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<>();
Copy link
Member

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);
Copy link
Member

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());
Copy link
Member

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?

@cbuescher
Copy link
Member Author

After discussion with @tlrx and @javanna we decided to close this in favour of #24564

@cbuescher cbuescher closed this May 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants