From 5a4124d4fbf8e186b9999c562e3496aca244ee66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Tue, 30 May 2017 15:21:02 +0200 Subject: [PATCH] Fixing template rendering after changes in master --- modules/rank-eval/build.gradle | 4 ---- .../index/rankeval/TransportRankEvalAction.java | 17 ++++++++--------- .../rank_eval/{10_basic.yaml => 10_basic.yml} | 0 .../test/rank_eval/{20_dcg.yaml => 20_dcg.yml} | 0 .../{30_failures.yaml => 30_failures.yml} | 0 ...TestRankEvalWithMustacheYAMLTestSuiteIT.java | 4 +--- 6 files changed, 9 insertions(+), 16 deletions(-) rename modules/rank-eval/src/test/resources/rest-api-spec/test/rank_eval/{10_basic.yaml => 10_basic.yml} (100%) rename modules/rank-eval/src/test/resources/rest-api-spec/test/rank_eval/{20_dcg.yaml => 20_dcg.yml} (100%) rename modules/rank-eval/src/test/resources/rest-api-spec/test/rank_eval/{30_failures.yaml => 30_failures.yml} (100%) diff --git a/modules/rank-eval/build.gradle b/modules/rank-eval/build.gradle index 1be16253b27..2c18fc40a08 100644 --- a/modules/rank-eval/build.gradle +++ b/modules/rank-eval/build.gradle @@ -22,7 +22,3 @@ esplugin { classname 'org.elasticsearch.index.rankeval.RankEvalPlugin' } -integTestCluster { - setting 'script.inline', 'true' - setting 'script.stored', 'true' -} diff --git a/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/TransportRankEvalAction.java b/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/TransportRankEvalAction.java index eb775312b86..3891d4281db 100644 --- a/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/TransportRankEvalAction.java +++ b/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/TransportRankEvalAction.java @@ -26,19 +26,19 @@ import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.HandledTransportAction; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; -import org.elasticsearch.common.bytes.BytesReference; +import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.query.QueryParseContext; -import org.elasticsearch.script.CompiledScript; +import org.elasticsearch.script.ExecutableScript; import org.elasticsearch.script.Script; -import org.elasticsearch.script.ScriptContext; import org.elasticsearch.script.ScriptService; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.builder.SearchSourceBuilder; +import org.elasticsearch.template.CompiledTemplate; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; @@ -97,10 +97,10 @@ public class TransportRankEvalAction ratedRequests.size()); Map errors = new ConcurrentHashMap<>(ratedRequests.size()); - Map scriptsWithoutParams = new HashMap<>(); + Map scriptsWithoutParams = new HashMap<>(); for (Entry entry : qualityTask.getTemplates().entrySet()) { scriptsWithoutParams.put(entry.getKey(), - scriptService.compile(entry.getValue(), ScriptContext.Standard.SEARCH)); + scriptService.compileTemplate(entry.getValue(), ExecutableScript.CONTEXT)); } for (RatedRequest ratedRequest : ratedRequests) { @@ -110,10 +110,9 @@ public class TransportRankEvalAction if (ratedSearchSource == null) { Map params = ratedRequest.getParams(); String templateId = ratedRequest.getTemplateId(); - CompiledScript compiled = scriptsWithoutParams.get(templateId); - BytesReference resolvedRequest = (BytesReference) (scriptService - .executable(compiled, params).run()); - try (XContentParser subParser = createParser(namedXContentRegistry, resolvedRequest, + CompiledTemplate compiled = scriptsWithoutParams.get(templateId); + String resolvedRequest = compiled.run(params); + try (XContentParser subParser = createParser(namedXContentRegistry, new BytesArray(resolvedRequest), XContentType.JSON)) { QueryParseContext parseContext = new QueryParseContext(subParser); ratedSearchSource = SearchSourceBuilder.fromXContent(parseContext); diff --git a/modules/rank-eval/src/test/resources/rest-api-spec/test/rank_eval/10_basic.yaml b/modules/rank-eval/src/test/resources/rest-api-spec/test/rank_eval/10_basic.yml similarity index 100% rename from modules/rank-eval/src/test/resources/rest-api-spec/test/rank_eval/10_basic.yaml rename to modules/rank-eval/src/test/resources/rest-api-spec/test/rank_eval/10_basic.yml diff --git a/modules/rank-eval/src/test/resources/rest-api-spec/test/rank_eval/20_dcg.yaml b/modules/rank-eval/src/test/resources/rest-api-spec/test/rank_eval/20_dcg.yml similarity index 100% rename from modules/rank-eval/src/test/resources/rest-api-spec/test/rank_eval/20_dcg.yaml rename to modules/rank-eval/src/test/resources/rest-api-spec/test/rank_eval/20_dcg.yml diff --git a/modules/rank-eval/src/test/resources/rest-api-spec/test/rank_eval/30_failures.yaml b/modules/rank-eval/src/test/resources/rest-api-spec/test/rank_eval/30_failures.yml similarity index 100% rename from modules/rank-eval/src/test/resources/rest-api-spec/test/rank_eval/30_failures.yaml rename to modules/rank-eval/src/test/resources/rest-api-spec/test/rank_eval/30_failures.yml diff --git a/qa/smoke-test-rank-eval-with-mustache/src/test/java/org/elasticsearch/smoketest/SmokeTestRankEvalWithMustacheYAMLTestSuiteIT.java b/qa/smoke-test-rank-eval-with-mustache/src/test/java/org/elasticsearch/smoketest/SmokeTestRankEvalWithMustacheYAMLTestSuiteIT.java index 401bddd3439..8132b5851e2 100644 --- a/qa/smoke-test-rank-eval-with-mustache/src/test/java/org/elasticsearch/smoketest/SmokeTestRankEvalWithMustacheYAMLTestSuiteIT.java +++ b/qa/smoke-test-rank-eval-with-mustache/src/test/java/org/elasticsearch/smoketest/SmokeTestRankEvalWithMustacheYAMLTestSuiteIT.java @@ -25,8 +25,6 @@ import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; -import java.io.IOException; - public class SmokeTestRankEvalWithMustacheYAMLTestSuiteIT extends ESClientYamlSuiteTestCase { public SmokeTestRankEvalWithMustacheYAMLTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) { @@ -34,7 +32,7 @@ public class SmokeTestRankEvalWithMustacheYAMLTestSuiteIT extends ESClientYamlSu } @ParametersFactory - public static Iterable parameters() throws IOException { + public static Iterable parameters() throws Exception { return ESClientYamlSuiteTestCase.createParameters(); }