Hi,
We have a junit test to create nestedAggregations + subAggregations:
TermsAggregationBuilder expectedTerms = new TermsAggregationBuilder("agg");
expectedTerms.field("data.Nested.NestedInner.NestedInnerField");
expectedTerms.size(1000);
NestedAggregationBuilder expectedInnerNested = new NestedAggregationBuilder("nested", "data.Nested.NestedInner");
expectedInnerNested.subAggregation(expectedTerms);
NestedAggregationBuilder expectedParentNested = new NestedAggregationBuilder("nested1", "data.Nested");
expectedParentNested.subAggregation(expectedInnerNested);
expectedParentNested will have
{
"nested":{
"nested":{
"path":"data.Nested"
},
"aggregations":{
"nested":{
"nested":{
"path":"data.Nested.NestedInner"
},
"aggregations":{
"agg":{
"terms":{
"field":"data.Nested.NestedInner.NestedInnerField",
"size":1000,
"min_doc_count":1,
"shard_min_doc_count":0,
"show_term_doc_count_error":false,
"order":[
{
"_count":"desc"
},
{
"_key":"asc"
}
]
}
}
}
}
}
}
}
As far as I understand this test, we wanted to have
"nested":{
"path":"data.Nested",
"name": "nested"
}
instead of
"nested":{
"nested":{
"path":"data.Nested"
}
In java docs, I found `NestedAggregationBuilder(name, path), name - is name of Aggregation but not a node 'Nested'
A new client:
Aggregation.of(builder -> builder
.nested(n -> n.path("data.Nested"))
.aggregations("nested", n -> n.nested(s ->s.path("data.Nested.NestedInner").name("nested1"))).aggregations("agg",
a -> a.terms(t -> t.field("data.Nested.NestedInner.NestedInnerField").size(100))));
nested:{
"path": data.Nested.NestedInner
"name: nested1
}
I think it is OK.