Aggregation name must have cardinality 1 but was cardinality – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 7.9-8.9

Briefly, this error occurs when an Elasticsearch aggregation operation is attempted with a cardinality (number of unique values) other than 1. This could be due to incorrect configuration or data inconsistency. To resolve this, ensure that the field you’re aggregating has a cardinality of 1. If it’s a multi-valued field, consider using a different field or adjusting your data model. Alternatively, you could use a different type of aggregation that supports higher cardinalities.

This guide will help you check for common problems that cause the log ” Aggregation [” + name() + “] must have cardinality 1 but was [” + cardinality + “] ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: search, aggregations.

Log Context

Log “Aggregation [” + name() + “] must have cardinality 1 but was [” + cardinality + “]” class name is GlobalAggregatorFactory.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 + name
 + "]. Global aggregations can only be defined as top level aggregations"
 );
 }
 if (cardinality != CardinalityUpperBound.ONE) {
 throw new AggregationExecutionException("Aggregation [" + name() + "] must have cardinality 1 but was [" + cardinality + "]");
 }
 return new GlobalAggregator(name; factories; context; metadata);
 }
}

 

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?