From 7231ee832a9b143a3445b595447d9467de222461 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Dev=C3=A8ze?= Date: Wed, 29 Feb 2012 17:46:22 +0100 Subject: [PATCH] set missing create param in PutRequest --- .../put/TransportPutIndexTemplateAction.java | 3 ++- .../template/SimpleIndexTemplateTests.java | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/elasticsearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java b/src/main/java/org/elasticsearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java index 987df086f56..9f2ae0088f2 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java @@ -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 diff --git a/src/test/java/org/elasticsearch/test/integration/indices/template/SimpleIndexTemplateTests.java b/src/test/java/org/elasticsearch/test/integration/indices/template/SimpleIndexTemplateTests.java index 4e4e9631a5a..bdc7fa75913 100644 --- a/src/test/java/org/elasticsearch/test/integration/indices/template/SimpleIndexTemplateTests.java +++ b/src/test/java/org/elasticsearch/test/integration/indices/template/SimpleIndexTemplateTests.java @@ -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();