PreCollection not called on new Aggregator before use – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 7.5-7.1

Briefly, this error occurs when the preCollection method is not invoked on a new Aggregator object before it’s used in Elasticsearch. This is a necessary step to prepare the Aggregator for use. To resolve this issue, ensure that the preCollection method is called on the Aggregator object before any operations are performed on it. Also, check your code for any logical errors that might be causing the method to be skipped. Lastly, ensure that your Elasticsearch version is up-to-date as this could be a bug that’s fixed in a newer version.

This guide will help you check for common problems that cause the log ” preCollection not called on new Aggregator before use ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: search, aggregations.

Log Context

Log “preCollection not called on new Aggregator before use” class name is AggregatorBase.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 context.addReleasable(this);
 final SearchShardTarget shardTarget = context.shardTarget();
 // Register a safeguard to highlight any invalid construction logic (call to this constructor without subsequent preCollection call)
 collectableSubAggregators = new BucketCollector() {
 void badState(){
 throw new QueryPhaseExecutionException(shardTarget; "preCollection not called on new Aggregator before use"; null);
 }
 @Override
 public LeafBucketCollector getLeafCollector(LeafReaderContext reader) {
 badState();
 assert false;

 

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?