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

Opster Team

March-22, Version: 1.7-8.0

Before you begin reading this guide, we recommend you try running the Elasticsearch Error Check-Up which analyzes 2 JSON files to detect many configuration errors.

Briefly, this error occurs when you try to use top hits aggregation and time series aggregation together in a single query. Top hits aggregation is used to retrieve the most relevant documents for a given search query, whereas time series aggregation is used to group search results based on a time interval. These two aggregations cannot be used together as they serve different purposes. To resolve this issue, you can try to use only one of these aggregations in your query or split them into separate queries.

To easily locate the root cause and resolve this issue try AutoOps for Elasticsearch & OpenSearch. It diagnoses problems by analyzing hundreds of metrics collected by a lightweight agent and offers guidance for resolving them.

Take a self-guided product tour to see for yourself (no registration required).

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”classname  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;

 

Watch product tour

Try AutoOps to find & fix Elasticsearch problems

Analyze Your Cluster
Skip to content