From aebbc9bda8d4374b8ed96a2f97d1d1ad7f9d0cd5 Mon Sep 17 00:00:00 2001 From: markharwood Date: Tue, 29 Jan 2019 11:53:11 +0000 Subject: [PATCH] Changed mappings from String to convention of BytesReference --- .../client/indices/PutIndexTemplateRequest.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateRequest.java index 87fbe99c17e45..5f22691b046eb 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateRequest.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateRequest.java @@ -70,7 +70,7 @@ public class PutIndexTemplateRequest extends MasterNodeRequest aliases = new HashSet<>(); @@ -252,7 +252,8 @@ private PutIndexTemplateRequest internalMapping(Map source) { builder.map(source); Objects.requireNonNull(builder.contentType()); try { - mappings = XContentHelper.convertToJson(BytesReference.bytes(builder), false, false, builder.contentType()); + mappings = new BytesArray( + XContentHelper.convertToJson(BytesReference.bytes(builder), false, false, builder.contentType())); return this; } catch (IOException e) { throw new UncheckedIOException("failed to convert source to json", e); @@ -262,7 +263,7 @@ private PutIndexTemplateRequest internalMapping(Map source) { } } - public String mappings() { + public BytesReference mappings() { return this.mappings; } @@ -436,7 +437,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws if (mappings != null) { builder.field("mappings"); try (XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, - DeprecationHandler.THROW_UNSUPPORTED_OPERATION, mappings)) { + DeprecationHandler.THROW_UNSUPPORTED_OPERATION, mappings.utf8ToString())) { builder.copyCurrentStructure(parser); } }