Skip to content

Commit

Permalink
DOCS: Correct mapping tags in put-template api
Browse files Browse the repository at this point in the history
The mapping tags were not named consistently and not linked correctly.

Relates #30400
  • Loading branch information
dnhatn committed May 6, 2018
1 parent a03e74d commit 3e58463
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1621,7 +1621,7 @@ public void testPutTemplate() throws Exception {
// end::put-template-request-settings

{
// tag::create-put-template-request-mappings
// tag::put-template-request-mappings-json
request.mapping("tweet", // <1>
"{\n" +
" \"tweet\": {\n" +
Expand All @@ -1633,11 +1633,11 @@ public void testPutTemplate() throws Exception {
" }\n" +
"}", // <2>
XContentType.JSON);
// end::create-put-template-mappings
// end::put-template-request-mappings-json
assertTrue(client.indices().putTemplate(request).isAcknowledged());
}
{
//tag::put-template-mappings-map
//tag::put-template-request-mappings-map
Map<String, Object> jsonMap = new HashMap<>();
Map<String, Object> message = new HashMap<>();
message.put("type", "text");
Expand All @@ -1647,11 +1647,11 @@ public void testPutTemplate() throws Exception {
tweet.put("properties", properties);
jsonMap.put("tweet", tweet);
request.mapping("tweet", jsonMap); // <1>
//end::put-template-mappings-map
//end::put-template-request-mappings-map
assertTrue(client.indices().putTemplate(request).isAcknowledged());
}
{
//tag::put-template-mappings-xcontent
//tag::put-template-request-mappings-xcontent
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.startObject();
{
Expand All @@ -1671,13 +1671,13 @@ public void testPutTemplate() throws Exception {
}
builder.endObject();
request.mapping("tweet", builder); // <1>
//end::put-template-mappings-xcontent
//end::put-template-request-mappings-xcontent
assertTrue(client.indices().putTemplate(request).isAcknowledged());
}
{
//tag::put-template-mappings-shortcut
//tag::put-template-request-mappings-shortcut
request.mapping("tweet", "message", "type=text"); // <1>
//end::put-template-mappings-shortcut
//end::put-template-request-mappings-shortcut
assertTrue(client.indices().putTemplate(request).isAcknowledged());
}

Expand Down
8 changes: 4 additions & 4 deletions docs/java-rest/high-level/indices/put_template.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ template's patterns.

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-template-request-mappings]
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-template-request-mappings-json]
--------------------------------------------------
<1> The type to define
<2> The mapping for this type, provided as a JSON string
Expand All @@ -41,21 +41,21 @@ The mapping source can be provided in different ways in addition to the

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-template-mappings-map]
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-template-request-mappings-map]
--------------------------------------------------
<1> Mapping source provided as a `Map` which gets automatically converted
to JSON format

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-template-mappings-xcontent]
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-template-request-mappings-xcontent]
--------------------------------------------------
<1> Mapping source provided as an `XContentBuilder` object, the Elasticsearch
built-in helpers to generate JSON content

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-template-mappings-shortcut]
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-template-request-mappings-shortcut]
--------------------------------------------------
<1> Mapping source provided as `Object` key-pairs, which gets converted to
JSON format
Expand Down

0 comments on commit 3e58463

Please sign in to comment.