From adc9808eff19b01ea10c1a3e5220e2d38ba3bd8b Mon Sep 17 00:00:00 2001 From: javanna Date: Fri, 24 Feb 2017 15:19:46 +0100 Subject: [PATCH] Convert watcher search source to json If any format other than json is sent, it should get converted to json, as watcher works under the assumption that the script is a template, hence json. Original commit: elastic/x-pack-elasticsearch@554bcd306ba5872ad3334eca7abbb167e5130802 --- .../watcher/support/search/WatcherSearchTemplateRequest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequest.java b/plugin/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequest.java index 7a2c6b857cb..a3e13fb6c6d 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequest.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequest.java @@ -14,6 +14,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptType; @@ -195,7 +196,7 @@ public class WatcherSearchTemplateRequest implements ToXContentObject { } } else if (token == XContentParser.Token.START_OBJECT) { if (BODY_FIELD.match(currentFieldName)) { - try (XContentBuilder builder = XContentBuilder.builder(parser.contentType().xContent())) { + try (XContentBuilder builder = XContentFactory.jsonBuilder()) { builder.copyCurrentStructure(parser); searchSource = builder.bytes(); }