|
|
@@ -32,6 +32,7 @@ import org.elasticsearch.common.settings.Settings;
|
|
|
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
|
|
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;
|
|
|
@@ -82,8 +83,8 @@ public class TransportSearchTemplateAction extends HandledTransportAction<Search
|
|
|
|
|
|
// Executes the search
|
|
|
SearchRequest searchRequest = request.getRequest();
|
|
|
-
|
|
|
- try (XContentParser parser = XContentFactory.xContent(source).createParser(xContentRegistry, source)) {
|
|
|
+ //we can assume the template is always json as we convert it before compiling it
|
|
|
+ try (XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser(xContentRegistry, source)) {
|
|
|
SearchSourceBuilder builder = SearchSourceBuilder.searchSource();
|
|
|
builder.parseXContent(new QueryParseContext(parser));
|
|
|
builder.explain(request.isExplain());
|