Top hits aggregations cannot be used together with time series aggregations – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 8.1-8.9

Briefly, this error occurs when you try to use top hits aggregations and time series aggregations together in the same query in Elasticsearch. Elasticsearch does not support this combination due to the complexity and potential performance issues. To resolve this issue, you can separate these two types of aggregations into different queries. Alternatively, you can restructure your data or your query to avoid needing both types of aggregations at the same time.

This guide will help you check for common problems that cause the log ” Top hits aggregations cannot be used together with time series aggregations ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: search, aggregations.

Log Context

Log “Top hits aggregations cannot be used together with time series aggregations” class name is TopHitsAggregatorFactory.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 AggregatorFactories.Builder subFactories;
 Map metadata
 ) throws IOException {
 super(name; context; parent; subFactories; metadata);
 if (context.isInSortOrderExecutionRequired()) {
 throw new AggregationExecutionException("Top hits aggregations cannot be used together with time series aggregations");
 }
 this.from = from;
 this.size = size;
 this.explain = explain;
 this.version = version;

 

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?