Skip to content

Commit 464e4ab

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 d9b49bd commit 464e4ab

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/scripted/ScriptedMetricAggregator.java

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

7676
leafMapScript.setDocument(doc);
7777
leafMapScript.execute();
78-
CollectionUtils.ensureNoSelfReferences(aggState);
7978
}
8079
};
8180
}
@@ -98,4 +97,10 @@ public InternalAggregation buildEmptyAggregation() {
9897
return new InternalScriptedMetric(name, null, reduceScript, pipelineAggregators(), metaData());
9998
}
10099

100+
@Override
101+
protected void doPostCollection() throws IOException {
102+
CollectionUtils.ensureNoSelfReferences(aggState);
103+
104+
super.doPostCollection();
105+
}
101106
}

0 commit comments

Comments
 (0)