Hello everyone,
In a custom plugin, I would like to build an aggregation containing a sub aggregation that can be passed as parameter. I have a REST end point /_customagg/ that can accept aggregations as POST parameters : {"aggs": "myagg": {"terms": {"field": "test"}}}
In the plugin code, I need to be able to "merge" my aggregation builder with aggregations in parameter as sub aggregation (XContentBuilder).
When using subaggregation method from AggregationBuilder class, it seems to produce wrong query.
I've made a gist to reproduce my problem : https://gist.github.com/clement-tourriere/3571d3dc22a1cd33534f
I don't know if there is a better way to achieve what I'm trying to do, all other suggestions are welcome ;).