diff options
author | Ryan Ernst <ryan@iernst.net> | 2017-06-07 08:24:18 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-07 08:24:18 -0700 |
commit | 2057bbc6c5a578281b54881d1f7f7c369e35f2f1 (patch) | |
tree | f86717e6c09cd50821870c5b5cad5de1c56946db /core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits | |
parent | 26ec89173bc3a008070e081879e049f2eeecb614 (diff) |
Scripting: Remove unnecessary intermediate script compilation methods on QueryShardContext (#25093)
This commit removes wrapper methods on QueryShardContext used to compile
scripts. Instead, the script service is made accessible in the context,
and calls to compile can be made directly. This will ease transition to
each of those location becoming their own context, since they would no
longer be able to expect the same script class type.
Diffstat (limited to 'core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits')
-rw-r--r-- | core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregationBuilder.java | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregationBuilder.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregationBuilder.java index 31cd1681f8..2739427cfe 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregationBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregationBuilder.java @@ -27,6 +27,7 @@ import org.elasticsearch.common.io.stream.StreamOutput; 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.Script; import org.elasticsearch.script.ScriptContext; import org.elasticsearch.script.SearchScript; @@ -533,8 +534,9 @@ public class TopHitsAggregationBuilder extends AbstractAggregationBuilder<TopHit List<ScriptFieldsContext.ScriptField> fields = new ArrayList<>(); if (scriptFields != null) { for (ScriptField field : scriptFields) { - SearchScript.LeafFactory searchScript = context.getQueryShardContext().getSearchScript(field.script(), - SearchScript.CONTEXT); + QueryShardContext shardContext = context.getQueryShardContext(); + SearchScript.Factory factory = shardContext.getScriptService().compile(field.script(), SearchScript.CONTEXT); + SearchScript.LeafFactory searchScript = factory.newFactory(field.script().getParams(), shardContext.lookup()); fields.add(new org.elasticsearch.search.fetch.subphase.ScriptFieldsContext.ScriptField( field.fieldName(), searchScript, field.ignoreFailure())); } |