Skip to content

Commit 70871b5

Browse files
cbismuthcolings86
authored andcommitted
Check self references in metric agg after last doc collection (#33593) (#34001)
* Check self references in metric agg after last doc collection (#33593) * Revert 0aff5a3 (#33593) * Check self refs in metric agg only once in post collection hook (#33593) * Remove unnecessary mocking (#33593)
1 parent c0c6a28 commit 70871b5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

server/src/main/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricAggregator.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ public void collect(int doc, long bucket) throws IOException {
8080

8181
leafMapScript.setDocument(doc);
8282
leafMapScript.execute();
83-
CollectionUtils.ensureNoSelfReferences(aggState, "Scripted metric aggs map script");
8483
}
8584
};
8685
}
@@ -103,4 +102,10 @@ public InternalAggregation buildEmptyAggregation() {
103102
return new InternalScriptedMetric(name, null, reduceScript, pipelineAggregators(), metaData());
104103
}
105104

105+
@Override
106+
protected void doPostCollection() throws IOException {
107+
CollectionUtils.ensureNoSelfReferences(aggState, "Scripted metric aggs map script");
108+
109+
super.doPostCollection();
110+
}
106111
}

0 commit comments

Comments
 (0)