📣 极限科技诚招搜索运维工程师(Elasticsearch/Easysearch)- 全职/北京 👉 : 立即申请加入

版本: 7.5-7.1

简而言之,当在 Elasticsearch 中使用新的 Aggregator 对象之前未调用 preCollection 方法时,会发生此错误。这是准备聚合器使用的必要步骤。要解决此问题,请确保在对 Aggregator 对象执行任何操作之前调用 preCollection 方法。此外,检查代码中是否存在可能导致跳过该方法的逻辑错误。最后,确保您的 Elasticsearch 版本是最新的,因为这可能是已在较新版本中修复的错误。

日志上下文 #

日志"preCollection not called on new Aggregator before use"的类名是 AggregatorBase.java。 我们从 Elasticsearch 源代码中提取了以下内容,为那些寻求深入上下文的人提供参考:

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;