Found two aggregation type definitions in – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-7.15

Briefly, this error occurs when there are two aggregation type definitions in the same query. Elasticsearch does not allow multiple aggregations of the same type in a single query. To resolve this issue, you can either remove one of the aggregations or rename one of them to differentiate. Alternatively, you can nest one aggregation within another if they are related. Lastly, ensure that the syntax and structure of your query is correct to avoid such conflicts.

This guide will help you check for common problems that cause the log ” Found two aggregation type definitions in [ ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: aggregations, search.

Log Context

Log “Found two aggregation type definitions in [” class name is We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 subFactories = parseAggregators(parser; level + 1);
 if (aggBuilder != null) {
 throw new ParsingException(parser.getTokenLocation(); "Found two aggregation type definitions in ["
 + aggregationName + "]: [" + aggBuilder.getType() + "] and [" + fieldName + "]");
 }  try {
 aggBuilder = parser.namedObject(BaseAggregationBuilder.class; fieldName; aggregationName);


How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?