How to extend terms aggregation in elasticsearch

As terms aggregation will collect top size terms on each shard, so the
final result may not accuracy if the shard size is not big enough.

so, in order to promote the accuracy of terms aggregation, we may need 

to calculate a weighted value by size. if there are more

documents on the shard, the terms collected on this shard will be 

greater. This means that we do not collect same size terms on each


so, we want to develop a customized plug-in which has the same manner 

with terms aggregation and different way of collecting terms on each shard.

The simple way is to inherit from terms aggregation, and override the 

way of collecting terms on each shard, but this seems difficulty,

because some classes in terms aggregation can only be accessed in 

package scope like the Bucket class.

we can also copy the whole source code of terms aggregation into our 

customized plug-in, but I don't think this is a good way.

Is it a good way to inherit from terms aggregation in user customized 


And Is there a good way to extend the terms aggregation?



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