|
23 | 23 | import org.elasticsearch.common.io.stream.StreamInput; |
24 | 24 | import org.elasticsearch.common.io.stream.StreamOutput; |
25 | 25 | import org.elasticsearch.script.BucketAggregationSelectorScript; |
26 | | -import org.elasticsearch.script.BucketAggregationScript; |
27 | 26 | import org.elasticsearch.script.Script; |
28 | 27 | import org.elasticsearch.search.aggregations.InternalAggregation; |
29 | 28 | import org.elasticsearch.search.aggregations.InternalAggregation.ReduceContext; |
@@ -84,23 +83,12 @@ public InternalAggregation reduce(InternalAggregation aggregation, ReduceContext |
84 | 83 | List<? extends InternalMultiBucketAggregation.InternalBucket> buckets = originalAgg.getBuckets(); |
85 | 84 |
|
86 | 85 | List<InternalMultiBucketAggregation.InternalBucket> newBuckets = new ArrayList<>(); |
87 | | - if ("expression".equals(script.getLang())) { |
88 | | - BucketAggregationScript.Factory factory = |
89 | | - reduceContext.scriptService().compile(script, BucketAggregationScript.CONTEXT); |
90 | | - BucketAggregationScript executableScript = factory.newInstance(); |
91 | | - for (InternalMultiBucketAggregation.InternalBucket bucket : buckets) { |
92 | | - if (executableScript.execute(scriptArgs(originalAgg, bucket)) == 1.0) { |
93 | | - newBuckets.add(bucket); |
94 | | - } |
95 | | - } |
96 | | - } else { |
97 | | - BucketAggregationSelectorScript.Factory factory = |
98 | | - reduceContext.scriptService().compile(script, BucketAggregationSelectorScript.CONTEXT); |
99 | | - BucketAggregationSelectorScript executableScript = factory.newInstance(); |
100 | | - for (InternalMultiBucketAggregation.InternalBucket bucket : buckets) { |
101 | | - if (executableScript.execute(scriptArgs(originalAgg, bucket))) { |
102 | | - newBuckets.add(bucket); |
103 | | - } |
| 86 | + BucketAggregationSelectorScript.Factory factory = |
| 87 | + reduceContext.scriptService().compile(script, BucketAggregationSelectorScript.CONTEXT); |
| 88 | + BucketAggregationSelectorScript executableScript = factory.newInstance(); |
| 89 | + for (InternalMultiBucketAggregation.InternalBucket bucket : buckets) { |
| 90 | + if (executableScript.execute(scriptArgs(originalAgg, bucket))) { |
| 91 | + newBuckets.add(bucket); |
104 | 92 | } |
105 | 93 | } |
106 | 94 | return originalAgg.create(newBuckets); |
|
0 commit comments