Skip to content

Commit ee00523

Browse files
catalin-ursachijavanna
authored andcommitted
Removed redundant JSON object from Put Mapping docs (#28514)
1 parent 974ad68 commit ee00523

File tree

1 file changed

+19
-23
lines changed

1 file changed

+19
-23
lines changed

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -411,19 +411,21 @@ public void testPutMapping() throws IOException {
411411
request.type("tweet"); // <2>
412412
// end::put-mapping-request
413413

414-
// tag::put-mapping-request-source
415-
request.source(
416-
"{\n" +
417-
" \"tweet\": {\n" +
418-
" \"properties\": {\n" +
419-
" \"message\": {\n" +
420-
" \"type\": \"text\"\n" +
421-
" }\n" +
422-
" }\n" +
423-
" }\n" +
424-
"}", // <1>
425-
XContentType.JSON);
426-
// end::put-mapping-request-source
414+
{
415+
// tag::put-mapping-request-source
416+
request.source(
417+
"{\n" +
418+
" \"properties\": {\n" +
419+
" \"message\": {\n" +
420+
" \"type\": \"text\"\n" +
421+
" }\n" +
422+
" }\n" +
423+
"}", // <1>
424+
XContentType.JSON);
425+
// end::put-mapping-request-source
426+
PutMappingResponse putMappingResponse = client.indices().putMapping(request);
427+
assertTrue(putMappingResponse.isAcknowledged());
428+
}
427429

428430
{
429431
//tag::put-mapping-map
@@ -432,9 +434,7 @@ public void testPutMapping() throws IOException {
432434
message.put("type", "text");
433435
Map<String, Object> properties = new HashMap<>();
434436
properties.put("message", message);
435-
Map<String, Object> tweet = new HashMap<>();
436-
tweet.put("properties", properties);
437-
jsonMap.put("tweet", tweet);
437+
jsonMap.put("properties", properties);
438438
request.source(jsonMap); // <1>
439439
//end::put-mapping-map
440440
PutMappingResponse putMappingResponse = client.indices().putMapping(request);
@@ -445,15 +445,11 @@ public void testPutMapping() throws IOException {
445445
XContentBuilder builder = XContentFactory.jsonBuilder();
446446
builder.startObject();
447447
{
448-
builder.startObject("tweet");
448+
builder.startObject("properties");
449449
{
450-
builder.startObject("properties");
450+
builder.startObject("message");
451451
{
452-
builder.startObject("message");
453-
{
454-
builder.field("type", "text");
455-
}
456-
builder.endObject();
452+
builder.field("type", "text");
457453
}
458454
builder.endObject();
459455
}

0 commit comments

Comments
 (0)