diff --git a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java index a394166439d..a7f1d841bc3 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java @@ -482,7 +482,7 @@ public class MetaDataCreateIndexService extends AbstractComponent { try { byte[] templatesData = Streams.copyToByteArray(templatesFile); parser = XContentHelper.createParser(templatesData, 0, templatesData.length); - IndexTemplateMetaData template = IndexTemplateMetaData.Builder.fromXContent(parser); + IndexTemplateMetaData template = IndexTemplateMetaData.Builder.fromXContentStandalone(parser); if (Regex.simpleMatch(template.template(), request.index)) { templates.add(template); } diff --git a/src/test/java/org/elasticsearch/indices/template/IndexTemplateFileLoadingTests.java b/src/test/java/org/elasticsearch/indices/template/IndexTemplateFileLoadingTests.java index de451120370..d0f37ed83c4 100644 --- a/src/test/java/org/elasticsearch/indices/template/IndexTemplateFileLoadingTests.java +++ b/src/test/java/org/elasticsearch/indices/template/IndexTemplateFileLoadingTests.java @@ -58,7 +58,7 @@ public class IndexTemplateFileLoadingTests extends ElasticsearchIntegrationTest File dst = new File(templatesDir, "template.json"); // random template, one uses the 'setting.index.number_of_shards', the other 'settings.number_of_shards' - String template = Streams.copyToStringFromClasspath("/org/elasticsearch/indices/template/template" + randomInt(1) + ".json"); + String template = Streams.copyToStringFromClasspath("/org/elasticsearch/indices/template/template" + randomInt(2) + ".json"); Files.write(template, dst, Charsets.UTF_8); } catch (Exception e) { throw new RuntimeException(e); diff --git a/src/test/java/org/elasticsearch/indices/template/template0.json b/src/test/java/org/elasticsearch/indices/template/template0.json index 3b2ace1389b..ce677f64b4f 100644 --- a/src/test/java/org/elasticsearch/indices/template/template0.json +++ b/src/test/java/org/elasticsearch/indices/template/template0.json @@ -1,7 +1,9 @@ { - "template" : "foo*", - "settings" : { - "index.number_of_shards": 10, - "index.number_of_replicas": 0 - } + "template_1" : { + "template" : "foo*", + "settings" : { + "index.number_of_shards": 10, + "index.number_of_replicas": 0 + } + } } \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/indices/template/template1.json b/src/test/java/org/elasticsearch/indices/template/template1.json index f91866865e7..5ca82aa4a8d 100644 --- a/src/test/java/org/elasticsearch/indices/template/template1.json +++ b/src/test/java/org/elasticsearch/indices/template/template1.json @@ -1,7 +1,9 @@ { - "template" : "foo*", - "settings" : { - "number_of_shards": 10, - "number_of_replicas": 0 + "template_1" : { + "template" : "foo*", + "settings" : { + "number_of_shards": 10, + "number_of_replicas": 0 + } } } \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/indices/template/template2.json b/src/test/java/org/elasticsearch/indices/template/template2.json index c48169f15a5..bea03cc7e99 100644 --- a/src/test/java/org/elasticsearch/indices/template/template2.json +++ b/src/test/java/org/elasticsearch/indices/template/template2.json @@ -1,9 +1,11 @@ { - "template" : "foo*", - "settings" : { - "index" : { - "number_of_shards": 10, - "number_of_replicas": 0 + "template_1" : { + "template" : "foo*", + "settings" : { + "index" : { + "number_of_shards": 10, + "number_of_replicas": 0 + } } } } \ No newline at end of file