Skip to content

Commit

Permalink
Removed redundant JSON object from Put Mapping docs (#28514)
Browse files Browse the repository at this point in the history
  • Loading branch information
catalin-ursachi authored and javanna committed Feb 13, 2018
1 parent 974ad68 commit ee00523
Showing 1 changed file with 19 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -432,9 +434,7 @@ public void testPutMapping() throws IOException {
message.put("type", "text");
Map<String, Object> properties = new HashMap<>();
properties.put("message", message);
Map<String, Object> 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);
Expand All @@ -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();
}
Expand Down

0 comments on commit ee00523

Please sign in to comment.