Nested Terms Aggregation performance issue?

I ran into a performance issue today with nested Terms aggregations.
Performance took a 1000x dive (aggregation time went from ~10ms to
~10,000ms) when I added a terms aggregation as a sub-aggregation of an
existing term aggregation.

The nature of the data is that the sub-aggregation will only yield 1 bucket

  • so its not like there were a bazillion buckets - but we do kind of have a
    deep nesting of aggregations - and this particular aggregation lies at the
    leaf of all aggregations.

That said, would such a jump in performance be expected? Might it be a bug?
Should I create a simple test case to reproduce it?

(If youre wondering why I would do a term aggregation where I only expect 1
result - see!topic/elasticsearch/y5WTIIAxEPo)

Here is part of my request:

      "aggregations" : {
        "operatorId" : {
          "terms" : {
            "field" : "operatorId",
            "size" : 100
          "aggregations" : {  <<------ adding this subaggregation has a 

massive impact on perf.
"operatorFullName" : {
"terms" : {
"field" : "operatorFullName"


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
To view this discussion on the web visit
For more options, visit