Browse Source

Check self references in metric agg after last doc collection (#33593) (#34001)

* Check self references in metric agg after last doc collection (#33593)

* Revert 0aff5a30c5dbad9f476be14f34b81e2d1991bb0f (#33593)

* Check self refs in metric agg only once in post collection hook (#33593)

* Remove unnecessary mocking (#33593)
Christophe Bismuth 7 years ago
parent
commit
70871b5af7

+ 6 - 1
server/src/main/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricAggregator.java

@@ -80,7 +80,6 @@ class ScriptedMetricAggregator extends MetricsAggregator {
 
                 leafMapScript.setDocument(doc);
                 leafMapScript.execute();
-                CollectionUtils.ensureNoSelfReferences(aggState, "Scripted metric aggs map script");
             }
         };
     }
@@ -103,4 +102,10 @@ class ScriptedMetricAggregator extends MetricsAggregator {
         return new InternalScriptedMetric(name, null, reduceScript, pipelineAggregators(), metaData());
     }
 
+    @Override
+    protected void doPostCollection() throws IOException {
+        CollectionUtils.ensureNoSelfReferences(aggState, "Scripted metric aggs map script");
+
+        super.doPostCollection();
+    }
 }