Add Json aggregation string to SearchRequestBuilder in java API

I have a java app that makes use of the SearchRequestBuilder. Usually I perform the operation using this pseudocode:

SearchRequestBuilder sb;
AggregationBuilder agBuilder;
//omitted some boiler plate where these are instantiatehow

sb.addAggregation(agBuilder);

I have a requirement whereby the aggregations part of the query is in the form of a json string. I need to add it to the SearchRequestBuilder somehow. Is there a recommended way to do this ?

I thought I might be able to achieve it via the XContentBuilder , but I'm not sure if it's possible to add the results of this to a SearchRequestBuilder anymore, so I'm looking for suggestions. (and I was rather hoping there was a quicker way than me creating the boiler plate to work through the json and turn it into an AggregationBuilder myself) :slight_smile:

Many thanks,
Phil

My question is essentially the same as this one:

I presume the answer is the same ?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.