Hi,

A possible solution is :

TermsBuilder termsBuilder = null;
TermsBuilder root = null;
if (!aggregs.isEmpty()) {
        for (Aggreg aggreg : aggregs) {
                if (aggreg.aggregOk()) {
                        if (aggreg.isTerms()) {
                                if (termsBuilder != null) {
                                        TermsBuilder temp =
terms(aggreg.getKey()).field(aggreg.getField()).minDocCount(0).size(0);
                                        termsBuilder = 
termsBuilder.subAggregation(temp);
                                        termsBuilder = temp;
                                } else {
                                        termsBuilder =
terms(aggreg.getKey()).field(aggreg.getField()).minDocCount(0).size(0);
                                        root = termsBuilder;
                                }
                        }
                }
        }
}
termsBuilder = root;

Ben



--
View this message in context: 
http://elasticsearch-users.115913.n3.nabble.com/Java-API-for-multiple-sub-aggregations-tp4055253p4060618.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/1406279020831-4060618.post%40n3.nabble.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to