Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Better JSON output scoping #6985
Before this change each aggregation had to output an object field with its name and write its JSON inside that object. This allowed for badly behaved aggregations which could write JSON content in the root of the 'aggs' object. this change move the writing of the aggregation name to a level above the aggregation itself, ensuring that aggregations can only write within there own scope in the JSON output.
+1 on enforcing the serialization of the name.
Regarding the impl, I think it would be better to do the same thing that is done for the mappers: the base class has a
This way, if we get other call sites of Aggregation.toXContent in the future, they won't need to care about serializing the agg name themselves.
+1 on fixing 1.3 as well but I think both changes should reference the same issue.