set missing create param in PutRequest
This commit is contained in:
parent
1f6f81d840
commit
7231ee832a
|
@ -87,7 +87,8 @@ public class TransportPutIndexTemplateAction extends TransportMasterNodeOperatio
|
|||
.template(request.template())
|
||||
.order(request.order())
|
||||
.settings(request.settings())
|
||||
.mappings(request.mappings()),
|
||||
.mappings(request.mappings())
|
||||
.create(request.create()),
|
||||
|
||||
new MetaDataIndexTemplateService.PutListener() {
|
||||
@Override
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.test.integration.indices.template;
|
|||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.indices.IndexTemplateAlreadyExistsException;
|
||||
import org.elasticsearch.test.integration.AbstractNodesTests;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
|
@ -78,6 +79,24 @@ public class SimpleIndexTemplateTests extends AbstractNodesTests {
|
|||
.endObject().endObject().endObject())
|
||||
.execute().actionGet();
|
||||
|
||||
// test create param
|
||||
try {
|
||||
client.admin().indices().preparePutTemplate("template_2")
|
||||
.setTemplate("test*")
|
||||
.setCreate(true)
|
||||
.setOrder(1)
|
||||
.addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties")
|
||||
.startObject("field2").field("type", "string").field("store", "no").endObject()
|
||||
.endObject().endObject().endObject())
|
||||
.execute().actionGet();
|
||||
assertThat(false, equalTo(true));
|
||||
} catch (IndexTemplateAlreadyExistsException e) {
|
||||
// OK
|
||||
} catch (Exception e) {
|
||||
assertThat(false, equalTo(true));
|
||||
}
|
||||
|
||||
|
||||
// index something into test_index, will match on both templates
|
||||
client.prepareIndex("test_index", "type1", "1").setSource("field1", "value1", "field2", "value 2").setRefresh(true).execute().actionGet();
|
||||
|
||||
|
|
Loading…
Reference in New Issue