Skip to content

Commit

Permalink
[Remove] Types from PutIndexTemplateRequest and builder to reduce map…
Browse files Browse the repository at this point in the history
…ping to a string (#2510)

Signed-off-by: Suraj Singh <surajrider@gmail.com>
  • Loading branch information
dreamer-89 committed Mar 21, 2022
1 parent 4bb8add commit 59d1e69
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,9 @@ public void testIndexTemplates() throws Exception {
.preparePutTemplate("foo_template")
.setPatterns(Collections.singletonList("te*"))
.setOrder(0)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("properties")
.startObject("field1")
.field("type", "text")
Expand All @@ -182,7 +180,6 @@ public void testIndexTemplates() throws Exception {
.endObject()
.endObject()
.endObject()
.endObject()
)
.get();

Expand All @@ -191,19 +188,16 @@ public void testIndexTemplates() throws Exception {
.preparePutTemplate("fuu_template")
.setPatterns(Collections.singletonList("test*"))
.setOrder(1)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("properties")
.startObject("field2")
.field("type", "text")
.field("store", false)
.endObject()
.endObject()
.endObject()
.endObject()
)
.get();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,9 @@ public void testLatestVersionLoaded() throws Exception {
.preparePutTemplate("template_1")
.setPatterns(Collections.singletonList("te*"))
.setOrder(0)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("properties")
.startObject("field1")
.field("type", "text")
Expand All @@ -477,7 +475,6 @@ public void testLatestVersionLoaded() throws Exception {
.endObject()
.endObject()
.endObject()
.endObject()
)
.execute()
.actionGet();
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,9 @@ public void testSimpleIndexTemplateTests() throws Exception {
.setPatterns(Collections.singletonList("te*"))
.setSettings(indexSettings())
.setOrder(0)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("properties")
.startObject("field1")
.field("type", "text")
Expand All @@ -126,7 +124,6 @@ public void testSimpleIndexTemplateTests() throws Exception {
.endObject()
.endObject()
.endObject()
.endObject()
)
.get();

Expand All @@ -136,19 +133,16 @@ public void testSimpleIndexTemplateTests() throws Exception {
.setPatterns(Collections.singletonList("test*"))
.setSettings(indexSettings())
.setOrder(1)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("properties")
.startObject("field2")
.field("type", "text")
.field("store", false)
.endObject()
.endObject()
.endObject()
.endObject()
)
.get();

Expand All @@ -161,19 +155,16 @@ public void testSimpleIndexTemplateTests() throws Exception {
.setSettings(indexSettings())
.setCreate(true)
.setOrder(1)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("properties")
.startObject("field2")
.field("type", "text")
.field("store", false)
.endObject()
.endObject()
.endObject()
.endObject()
),
IllegalArgumentException.class
);
Expand Down Expand Up @@ -223,11 +214,9 @@ public void testDeleteIndexTemplate() throws Exception {
.preparePutTemplate("template_1")
.setPatterns(Collections.singletonList("te*"))
.setOrder(0)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("properties")
.startObject("field1")
.field("type", "text")
Expand All @@ -239,7 +228,6 @@ public void testDeleteIndexTemplate() throws Exception {
.endObject()
.endObject()
.endObject()
.endObject()
)
.execute()
.actionGet();
Expand All @@ -249,19 +237,16 @@ public void testDeleteIndexTemplate() throws Exception {
.preparePutTemplate("template_2")
.setPatterns(Collections.singletonList("test*"))
.setOrder(1)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("properties")
.startObject("field2")
.field("type", "text")
.field("store", false)
.endObject()
.endObject()
.endObject()
.endObject()
)
.execute()
.actionGet();
Expand All @@ -281,11 +266,9 @@ public void testDeleteIndexTemplate() throws Exception {
.preparePutTemplate("template_1")
.setPatterns(Collections.singletonList("te*"))
.setOrder(0)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("properties")
.startObject("field1")
.field("type", "text")
Expand All @@ -297,7 +280,6 @@ public void testDeleteIndexTemplate() throws Exception {
.endObject()
.endObject()
.endObject()
.endObject()
)
.execute()
.actionGet();
Expand All @@ -322,11 +304,9 @@ public void testThatGetIndexTemplatesWorks() throws Exception {
.setPatterns(Collections.singletonList("te*"))
.setOrder(0)
.setVersion(123)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("properties")
.startObject("field1")
.field("type", "text")
Expand All @@ -338,7 +318,6 @@ public void testThatGetIndexTemplatesWorks() throws Exception {
.endObject()
.endObject()
.endObject()
.endObject()
)
.execute()
.actionGet();
Expand Down Expand Up @@ -367,11 +346,9 @@ public void testThatGetIndexTemplatesWithSimpleRegexWorks() throws Exception {
.preparePutTemplate("template_1")
.setPatterns(Collections.singletonList("te*"))
.setOrder(0)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("properties")
.startObject("field1")
.field("type", "text")
Expand All @@ -383,7 +360,6 @@ public void testThatGetIndexTemplatesWithSimpleRegexWorks() throws Exception {
.endObject()
.endObject()
.endObject()
.endObject()
)
.execute()
.actionGet();
Expand All @@ -394,11 +370,9 @@ public void testThatGetIndexTemplatesWithSimpleRegexWorks() throws Exception {
.preparePutTemplate("template_2")
.setPatterns(Collections.singletonList("te*"))
.setOrder(0)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("properties")
.startObject("field1")
.field("type", "text")
Expand All @@ -410,7 +384,6 @@ public void testThatGetIndexTemplatesWithSimpleRegexWorks() throws Exception {
.endObject()
.endObject()
.endObject()
.endObject()
)
.execute()
.actionGet();
Expand All @@ -421,11 +394,9 @@ public void testThatGetIndexTemplatesWithSimpleRegexWorks() throws Exception {
.preparePutTemplate("template3")
.setPatterns(Collections.singletonList("te*"))
.setOrder(0)
.addMapping(
"type1",
.setMapping(
XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("properties")
.startObject("field1")
.field("type", "text")
Expand All @@ -437,7 +408,6 @@ public void testThatGetIndexTemplatesWithSimpleRegexWorks() throws Exception {
.endObject()
.endObject()
.endObject()
.endObject()
)
.execute()
.actionGet();
Expand Down Expand Up @@ -507,7 +477,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 +866,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 +913,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 +927,6 @@ public void testMultipleTemplate() throws IOException {
.endObject()
.endObject()
.endObject()
.endObject()
)
.get();

Expand Down Expand Up @@ -1027,7 +991,7 @@ public void testPartitionedTemplate() throws Exception {
.indices()
.preparePutTemplate("template_2")
.setPatterns(Collections.singletonList("te*"))
.addMapping("type", "{\"type\":{\"_routing\":{\"required\":false}}}", XContentType.JSON)
.setMapping("{\"_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 59d1e69

Please sign in to comment.