diff --git a/core/src/main/java/org/elasticsearch/index/query/QueryShardContext.java b/core/src/main/java/org/elasticsearch/index/query/QueryShardContext.java index 671a89a3884..200d5fde0c7 100644 --- a/core/src/main/java/org/elasticsearch/index/query/QueryShardContext.java +++ b/core/src/main/java/org/elasticsearch/index/query/QueryShardContext.java @@ -341,7 +341,8 @@ public class QueryShardContext extends QueryRewriteContext { return scriptService.search(lookup(), script, context, params); } - public Function, SearchScript> getLazySearchScript(Script script, ScriptContext context, Map params) { + public Function, SearchScript> getLazySearchScript(Script script, ScriptContext context, + Map params) { failIfExecutionMode(); markAsNotCachable(); CompiledScript compile = scriptService.compile(script, context, params); @@ -354,7 +355,8 @@ public class QueryShardContext extends QueryRewriteContext { return scriptService.executable(script, context, params); } - public Function, ExecutableScript> getLazyExecutableScript(Script script, ScriptContext context, Map params) { + public Function, ExecutableScript> getLazyExecutableScript(Script script, ScriptContext context, + Map params) { failIfExecutionMode(); markAsNotCachable(); CompiledScript executable = scriptService.compile(script, context, params); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/ScriptedMetricAggregationBuilder.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/ScriptedMetricAggregationBuilder.java index 208fae15701..f044e94f05b 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/ScriptedMetricAggregationBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/ScriptedMetricAggregationBuilder.java @@ -27,25 +27,18 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.query.QueryParseContext; import org.elasticsearch.index.query.QueryShardContext; -import org.elasticsearch.script.CompiledScript; import org.elasticsearch.script.ExecutableScript; import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptContext; import org.elasticsearch.script.SearchScript; -import org.elasticsearch.search.SearchParseException; import org.elasticsearch.search.aggregations.AbstractAggregationBuilder; import org.elasticsearch.search.aggregations.AggregatorFactories.Builder; import org.elasticsearch.search.aggregations.AggregatorFactory; import org.elasticsearch.search.aggregations.InternalAggregation.Type; import org.elasticsearch.search.aggregations.support.AggregationContext; -import org.elasticsearch.search.internal.SearchContext; - import java.io.IOException; -import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; @@ -212,8 +205,8 @@ public class ScriptedMetricAggregationBuilder extends AbstractAggregationBuilder } else { executableCombineScript = (p) -> null; } - return new ScriptedMetricAggregatorFactory(name, type, searchMapScript, executableInitScript, executableCombineScript, reduceScript, params, context, - parent, subfactoriesBuilder, metaData); + return new ScriptedMetricAggregatorFactory(name, type, searchMapScript, executableInitScript, executableCombineScript, reduceScript, + params, context, parent, subfactoriesBuilder, metaData); } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/ScriptedMetricAggregatorFactory.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/ScriptedMetricAggregatorFactory.java index 1dc02ea42dc..d6150fa8743 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/ScriptedMetricAggregatorFactory.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/ScriptedMetricAggregatorFactory.java @@ -19,8 +19,6 @@ package org.elasticsearch.search.aggregations.metrics.scripted; -import org.elasticsearch.index.query.QueryShardContext; -import org.elasticsearch.script.CompiledScript; import org.elasticsearch.script.ExecutableScript; import org.elasticsearch.script.Script; import org.elasticsearch.script.SearchScript; @@ -38,7 +36,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.function.Function; public class ScriptedMetricAggregatorFactory extends AggregatorFactory { @@ -49,9 +46,10 @@ public class ScriptedMetricAggregatorFactory extends AggregatorFactory params; private final Function, ExecutableScript> initScript; - public ScriptedMetricAggregatorFactory(String name, Type type, Function, SearchScript> mapScript, Function, ExecutableScript> initScript, Function, ExecutableScript> combineScript, - Script reduceScript, Map params, AggregationContext context, AggregatorFactory parent, - AggregatorFactories.Builder subFactories, Map metaData) throws IOException { + public ScriptedMetricAggregatorFactory(String name, Type type, Function, SearchScript> mapScript, + Function, ExecutableScript> initScript, Function, ExecutableScript> combineScript, + Script reduceScript, Map params, AggregationContext context, AggregatorFactory parent, + AggregatorFactories.Builder subFactories, Map metaData) throws IOException { super(name, type, context, parent, subFactories, metaData); this.mapScript = mapScript; this.initScript = initScript; @@ -111,7 +109,7 @@ public class ScriptedMetricAggregatorFactory extends AggregatorFactory originalList = (List) original; - List clonedList = new ArrayList(); + List clonedList = new ArrayList<>(); for (Object o : originalList) { clonedList.add(deepCopyParams(o, context)); } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregatorFactory.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregatorFactory.java index 42477c3212f..8e1c0c51095 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregatorFactory.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregatorFactory.java @@ -19,15 +19,12 @@ package org.elasticsearch.search.aggregations.metrics.tophits; -import org.elasticsearch.script.ScriptContext; -import org.elasticsearch.script.SearchScript; import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.AggregatorFactories; import org.elasticsearch.search.aggregations.AggregatorFactory; import org.elasticsearch.search.aggregations.InternalAggregation.Type; import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; -import org.elasticsearch.search.builder.SearchSourceBuilder.ScriptField; import org.elasticsearch.search.fetch.StoredFieldsContext; import org.elasticsearch.search.fetch.subphase.DocValueFieldsContext; import org.elasticsearch.search.fetch.subphase.FetchSourceContext; @@ -38,11 +35,9 @@ import org.elasticsearch.search.sort.SortAndFormats; import org.elasticsearch.search.sort.SortBuilder; import java.io.IOException; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.Set; public class TopHitsAggregatorFactory extends AggregatorFactory { @@ -59,10 +54,10 @@ public class TopHitsAggregatorFactory extends AggregatorFactory> sorts, HighlightBuilder highlightBuilder, StoredFieldsContext storedFieldsContext, - List docValueFields, List scriptFields, FetchSourceContext fetchSourceContext, - AggregationContext context, AggregatorFactory parent, AggregatorFactories.Builder subFactories, - Map metaData) throws IOException { + List> sorts, HighlightBuilder highlightBuilder, StoredFieldsContext storedFieldsContext, + List docValueFields, List scriptFields, FetchSourceContext fetchSourceContext, + AggregationContext context, AggregatorFactory parent, AggregatorFactories.Builder subFactories, Map metaData) + throws IOException { super(name, type, context, parent, subFactories, metaData); this.from = from; this.size = size;