SubAggregation Performance

The following queries (two level) take around 1minute to finish,

query1 : DateHistogram.subAggregation(TermsBuilderOnField1.subAggregation(TermsBuilderOnField2))
query2 : DateHistogram.subAggregation(TermsBuilderOnField2.subAggregation(TermsBuilderOnField1))

Field1 - int field (Possible values are 1 to 10)
Field2 - Long (High cardinality field basically a user ID)
Version - 2.3.2

Some insights on my data,

  1. daily indices with 2 copies , average size of 50GB for per copy (100GB for 2 copy)
  2. Around 400 million docs in per day index
  3. 3 machines with 128 GB RAM (Running as 6 nodes. 30GB assigned to each JVM )