Multiple Sum subaggregations at same level using Java API

Any way to add the subaggregations to my query? I'm trying to clean up my code. Here's what it looks like now.

builder.setQuery(query)
   .addAggregation(AggregationBuilders.terms("group_by_this_field").field("this_field")
		  .subAggregation(AggregationBuilders.terms("group_by_that_field")
											 .field("that_field")
											 .subAggregation(AggregationBuilders
													 .sum("field_1")
													 .field("field_1"))
											 .subAggregation(AggregationBuilders
													 .sum("field_2")
													 .field("field_2"))
											 .subAggregation(AggregationBuilders
													 .sum("field_3")
													 .field("field_3")).subAggregation(AggregationBuilders
														 .topHits("agg_source")
														 .fetchSource(aggSource, new String[0])))));

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