From ee00523737381bd0494f307dedd4907b5847daef Mon Sep 17 00:00:00 2001 From: Catalin Ursachi Date: Tue, 13 Feb 2018 16:20:35 +0000 Subject: [PATCH] Removed redundant JSON object from Put Mapping docs (#28514) --- .../IndicesClientDocumentationIT.java | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java index f43ec7b3e283a..0462454f29829 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java @@ -411,19 +411,21 @@ public void testPutMapping() throws IOException { request.type("tweet"); // <2> // end::put-mapping-request - // tag::put-mapping-request-source - request.source( - "{\n" + - " \"tweet\": {\n" + - " \"properties\": {\n" + - " \"message\": {\n" + - " \"type\": \"text\"\n" + - " }\n" + - " }\n" + - " }\n" + - "}", // <1> - XContentType.JSON); - // end::put-mapping-request-source + { + // tag::put-mapping-request-source + request.source( + "{\n" + + " \"properties\": {\n" + + " \"message\": {\n" + + " \"type\": \"text\"\n" + + " }\n" + + " }\n" + + "}", // <1> + XContentType.JSON); + // end::put-mapping-request-source + PutMappingResponse putMappingResponse = client.indices().putMapping(request); + assertTrue(putMappingResponse.isAcknowledged()); + } { //tag::put-mapping-map @@ -432,9 +434,7 @@ public void testPutMapping() throws IOException { message.put("type", "text"); Map properties = new HashMap<>(); properties.put("message", message); - Map tweet = new HashMap<>(); - tweet.put("properties", properties); - jsonMap.put("tweet", tweet); + jsonMap.put("properties", properties); request.source(jsonMap); // <1> //end::put-mapping-map PutMappingResponse putMappingResponse = client.indices().putMapping(request); @@ -445,15 +445,11 @@ public void testPutMapping() throws IOException { XContentBuilder builder = XContentFactory.jsonBuilder(); builder.startObject(); { - builder.startObject("tweet"); + builder.startObject("properties"); { - builder.startObject("properties"); + builder.startObject("message"); { - builder.startObject("message"); - { - builder.field("type", "text"); - } - builder.endObject(); + builder.field("type", "text"); } builder.endObject(); }