Fixing template rendering after changes in master
This commit is contained in:
parent
3d6fb4eb0b
commit
5a4124d4fb
|
@ -22,7 +22,3 @@ esplugin {
|
|||
classname 'org.elasticsearch.index.rankeval.RankEvalPlugin'
|
||||
}
|
||||
|
||||
integTestCluster {
|
||||
setting 'script.inline', 'true'
|
||||
setting 'script.stored', 'true'
|
||||
}
|
||||
|
|
|
@ -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<String, Exception> errors = new ConcurrentHashMap<>(ratedRequests.size());
|
||||
|
||||
Map<String, CompiledScript> scriptsWithoutParams = new HashMap<>();
|
||||
Map<String, CompiledTemplate> scriptsWithoutParams = new HashMap<>();
|
||||
for (Entry<String, Script> 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<String, Object> 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);
|
||||
|
|
|
@ -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<Object[]> parameters() throws IOException {
|
||||
public static Iterable<Object[]> parameters() throws Exception {
|
||||
return ESClientYamlSuiteTestCase.createParameters();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue