Problem with binary sub aggregations


#1

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 ;).


(Colin Goodheart-Smithe) #2

This looks like a bug. I've raised this issue on github for it: https://github.com/elastic/elasticsearch/issues/11457

Thanks for raising this issue. Unfortunately I can't think of a workaround for this.


#3

Thank you Colin for your response and your quick fix. Just need to wait for the next release now :).


(system) #4