summaryrefslogtreecommitdiff
path: root/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/TransportSearchTemplateAction.java
diff options
context:
space:
mode:
authorRyan Ernst <ryan@iernst.net>2017-05-25 12:18:45 -0700
committerGitHub <noreply@github.com>2017-05-25 12:18:45 -0700
commit8aaea51a0a0d822e67404e3af6b970e8a323b877 (patch)
tree1d008a9db65c784419fe6edfcb93e365bc103c7e /modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/TransportSearchTemplateAction.java
parent59c052e76f7428427c8f7e995285bd0b05e82c08 (diff)
Scripting: Move context definitions to instance type classes (#24883)
This is a simple refactoring to move the context definitions into the type that they use. While we have multiple context names for the same class at the moment, this will eventually become one ScriptContext per instance type, so the pattern of a static member on the interface called CONTEXT can be used. This commit also moves the consolidated list of contexts provided by core ES into ScriptModule.
Diffstat (limited to 'modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/TransportSearchTemplateAction.java')
-rw-r--r--modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/TransportSearchTemplateAction.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/TransportSearchTemplateAction.java b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/TransportSearchTemplateAction.java
index ca25147405..faf543e2a0 100644
--- a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/TransportSearchTemplateAction.java
+++ b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/TransportSearchTemplateAction.java
@@ -34,6 +34,7 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.query.QueryParseContext;
+import org.elasticsearch.script.ExecutableScript;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.search.builder.SearchSourceBuilder;
@@ -44,7 +45,7 @@ import org.elasticsearch.transport.TransportService;
import java.io.IOException;
import java.util.Collections;
-import static org.elasticsearch.script.ScriptContext.EXECUTABLE;
+import static org.elasticsearch.script.ExecutableScript.CONTEXT;
public class TransportSearchTemplateAction extends HandledTransportAction<SearchTemplateRequest, SearchTemplateResponse> {
@@ -100,7 +101,7 @@ public class TransportSearchTemplateAction extends HandledTransportAction<Search
NamedXContentRegistry xContentRegistry) throws IOException {
Script script = new Script(searchTemplateRequest.getScriptType(), TEMPLATE_LANG, searchTemplateRequest.getScript(),
searchTemplateRequest.getScriptParams() == null ? Collections.emptyMap() : searchTemplateRequest.getScriptParams());
- CompiledTemplate compiledScript = scriptService.compileTemplate(script, EXECUTABLE);
+ CompiledTemplate compiledScript = scriptService.compileTemplate(script, ExecutableScript.CONTEXT);
String source = compiledScript.run(script.getParams());
response.setSource(new BytesArray(source));