Remove content type auto-detection from search templates
Now that search templates always get converted to json, we don't need to try and auto-detect their content-type, which anyways didn't work as expected before given that only json was really working.
This commit is contained in:
parent
f2acf466aa
commit
594f00c582
|
@ -26,6 +26,7 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.xcontent.StatusToXContentObject;
|
import org.elasticsearch.common.xcontent.StatusToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.rest.RestStatus;
|
import org.elasticsearch.rest.RestStatus;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -81,7 +82,8 @@ public class SearchTemplateResponse extends ActionResponse implements StatusToX
|
||||||
response.toXContent(builder, params);
|
response.toXContent(builder, params);
|
||||||
} else {
|
} else {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
builder.rawField("template_output", source);
|
//we can assume the template is always json as we convert it before compiling it
|
||||||
|
builder.rawField("template_output", source, XContentType.JSON);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
return builder;
|
return builder;
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.index.query.QueryParseContext;
|
import org.elasticsearch.index.query.QueryParseContext;
|
||||||
import org.elasticsearch.script.ExecutableScript;
|
import org.elasticsearch.script.ExecutableScript;
|
||||||
import org.elasticsearch.script.Script;
|
import org.elasticsearch.script.Script;
|
||||||
|
@ -82,8 +83,8 @@ public class TransportSearchTemplateAction extends HandledTransportAction<Search
|
||||||
|
|
||||||
// Executes the search
|
// Executes the search
|
||||||
SearchRequest searchRequest = request.getRequest();
|
SearchRequest searchRequest = request.getRequest();
|
||||||
|
//we can assume the template is always json as we convert it before compiling it
|
||||||
try (XContentParser parser = XContentFactory.xContent(source).createParser(xContentRegistry, source)) {
|
try (XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser(xContentRegistry, source)) {
|
||||||
SearchSourceBuilder builder = SearchSourceBuilder.searchSource();
|
SearchSourceBuilder builder = SearchSourceBuilder.searchSource();
|
||||||
builder.parseXContent(new QueryParseContext(parser));
|
builder.parseXContent(new QueryParseContext(parser));
|
||||||
builder.explain(request.isExplain());
|
builder.explain(request.isExplain());
|
||||||
|
|
Loading…
Reference in New Issue