Skip to content

Commit

Permalink
[Remove] PutIndexTemplateRequest and builder contains a single mapping
Browse files Browse the repository at this point in the history
Signed-off-by: Suraj Singh <[email protected]>
  • Loading branch information
dreamer-89 committed Mar 18, 2022
1 parent 9f83dea commit 6f0774e
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 151 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,10 @@ public void testIndexTemplates() throws Exception {
.preparePutTemplate("foo_template")
.setPatterns(Collections.singletonList("te*"))
.setOrder(0)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("_doc")
.startObject("properties")
.startObject("field1")
.field("type", "text")
Expand All @@ -191,11 +190,10 @@ public void testIndexTemplates() throws Exception {
.preparePutTemplate("fuu_template")
.setPatterns(Collections.singletonList("test*"))
.setOrder(1)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("_doc")
.startObject("properties")
.startObject("field2")
.field("type", "text")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,10 @@ public void testLatestVersionLoaded() throws Exception {
.preparePutTemplate("template_1")
.setPatterns(Collections.singletonList("te*"))
.setOrder(0)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("_doc")
.startObject("properties")
.startObject("field1")
.field("type", "text")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@ public void testIndexTemplatesWithBlocks() throws IOException {
.preparePutTemplate("template_blocks")
.setPatterns(Collections.singletonList("te*"))
.setOrder(0)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("properties")
.startObject("field1")
.field("type", "text")
Expand All @@ -70,7 +68,6 @@ public void testIndexTemplatesWithBlocks() throws IOException {
.endObject()
.endObject()
.endObject()
.endObject()
)
.execute()
.actionGet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,10 @@ public void testSimpleIndexTemplateTests() throws Exception {
.setPatterns(Collections.singletonList("te*"))
.setSettings(indexSettings())
.setOrder(0)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("_doc")
.startObject("properties")
.startObject("field1")
.field("type", "text")
Expand All @@ -136,11 +135,10 @@ public void testSimpleIndexTemplateTests() throws Exception {
.setPatterns(Collections.singletonList("test*"))
.setSettings(indexSettings())
.setOrder(1)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("_doc")
.startObject("properties")
.startObject("field2")
.field("type", "text")
Expand All @@ -161,11 +159,10 @@ public void testSimpleIndexTemplateTests() throws Exception {
.setSettings(indexSettings())
.setCreate(true)
.setOrder(1)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("_doc")
.startObject("properties")
.startObject("field2")
.field("type", "text")
Expand Down Expand Up @@ -223,11 +220,10 @@ public void testDeleteIndexTemplate() throws Exception {
.preparePutTemplate("template_1")
.setPatterns(Collections.singletonList("te*"))
.setOrder(0)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("_doc")
.startObject("properties")
.startObject("field1")
.field("type", "text")
Expand All @@ -249,11 +245,10 @@ public void testDeleteIndexTemplate() throws Exception {
.preparePutTemplate("template_2")
.setPatterns(Collections.singletonList("test*"))
.setOrder(1)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("_doc")
.startObject("properties")
.startObject("field2")
.field("type", "text")
Expand Down Expand Up @@ -281,8 +276,7 @@ public void testDeleteIndexTemplate() throws Exception {
.preparePutTemplate("template_1")
.setPatterns(Collections.singletonList("te*"))
.setOrder(0)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
Expand Down Expand Up @@ -322,11 +316,10 @@ public void testThatGetIndexTemplatesWorks() throws Exception {
.setPatterns(Collections.singletonList("te*"))
.setOrder(0)
.setVersion(123)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("_doc")
.startObject("properties")
.startObject("field1")
.field("type", "text")
Expand Down Expand Up @@ -367,11 +360,10 @@ public void testThatGetIndexTemplatesWithSimpleRegexWorks() throws Exception {
.preparePutTemplate("template_1")
.setPatterns(Collections.singletonList("te*"))
.setOrder(0)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("_doc")
.startObject("properties")
.startObject("field1")
.field("type", "text")
Expand All @@ -394,11 +386,10 @@ public void testThatGetIndexTemplatesWithSimpleRegexWorks() throws Exception {
.preparePutTemplate("template_2")
.setPatterns(Collections.singletonList("te*"))
.setOrder(0)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("_doc")
.startObject("properties")
.startObject("field1")
.field("type", "text")
Expand All @@ -421,11 +412,10 @@ public void testThatGetIndexTemplatesWithSimpleRegexWorks() throws Exception {
.preparePutTemplate("template3")
.setPatterns(Collections.singletonList("te*"))
.setOrder(0)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("_doc")
.startObject("properties")
.startObject("field1")
.field("type", "text")
Expand Down Expand Up @@ -507,7 +497,7 @@ public void testBrokenMapping() throws Exception {
.indices()
.preparePutTemplate("template_1")
.setPatterns(Collections.singletonList("te*"))
.addMapping("type1", "{\"foo\": \"abcde\"}", XContentType.JSON)
.setMapping("{\"foo\": \"abcde\"}", XContentType.JSON)
.get()
);
assertThat(e.getMessage(), containsString("Failed to parse mapping "));
Expand Down Expand Up @@ -896,19 +886,16 @@ public void testCombineTemplates() throws Exception {
.setPatterns(Collections.singletonList("test*"))
.setCreate(true)
.setOrder(1)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("properties")
.startObject("field2")
.field("type", "text")
.field("analyzer", "custom_1")
.endObject()
.endObject()
.endObject()
.endObject()
)
.get()
);
Expand Down Expand Up @@ -946,11 +933,9 @@ public void testMultipleTemplate() throws IOException {
.preparePutTemplate("template_1")
.setPatterns(Arrays.asList("a*", "b*"))
.setSettings(indexSettings())
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("properties")
.startObject("field1")
.field("type", "text")
Expand All @@ -962,7 +947,6 @@ public void testMultipleTemplate() throws IOException {
.endObject()
.endObject()
.endObject()
.endObject()
)
.get();

Expand Down Expand Up @@ -1027,7 +1011,7 @@ public void testPartitionedTemplate() throws Exception {
.indices()
.preparePutTemplate("template_2")
.setPatterns(Collections.singletonList("te*"))
.addMapping("type", "{\"type\":{\"_routing\":{\"required\":false}}}", XContentType.JSON)
.setMapping("{\"type\":{\"_routing\":{\"required\":false}}}", XContentType.JSON)
.setSettings(Settings.builder().put("index.number_of_shards", "6").put("index.routing_partition_size", "3"))
.get()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,9 @@ public void testRestoreTemplates() throws Exception {
.indices()
.preparePutTemplate("test-template")
.setPatterns(Collections.singletonList("te*"))
.addMapping(
"_doc",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("_doc")
.startObject("properties")
.startObject("field1")
.field("type", "text")
Expand All @@ -440,7 +438,6 @@ public void testRestoreTemplates() throws Exception {
.endObject()
.endObject()
.endObject()
.endObject()
)
.get()
.isAcknowledged(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,9 @@ public void testIncludeGlobalState() throws Exception {
.indices()
.preparePutTemplate("test-template")
.setPatterns(Collections.singletonList("te*"))
.addMapping(
"_doc",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("_doc")
.startObject("properties")
.startObject("field1")
.field("type", "text")
Expand All @@ -97,7 +95,6 @@ public void testIncludeGlobalState() throws Exception {
.endObject()
.endObject()
.endObject()
.endObject()
)
.get()
.isAcknowledged(),
Expand Down
Loading

0 comments on commit 6f0774e

Please sign in to comment.