From a96f9a7c8376a4782d6571160c1e316867dc2a1b Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Wed, 2 Jul 2014 08:42:31 +0200 Subject: [PATCH] Templates: GET templates doesn't honor the `flat_settings` parameter. Close #6671 --- .../test/indices.get_template/10_basic.yaml | 13 ++++++++++++- .../test/indices.put_template/10_basic.yaml | 2 ++ .../cluster/metadata/IndexTemplateMetaData.java | 4 +--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/rest-api-spec/test/indices.get_template/10_basic.yaml b/rest-api-spec/test/indices.get_template/10_basic.yaml index f5a4cadccc9..bc93ee92540 100644 --- a/rest-api-spec/test/indices.get_template/10_basic.yaml +++ b/rest-api-spec/test/indices.get_template/10_basic.yaml @@ -16,7 +16,8 @@ setup: name: test - match: {test.template: "test-*"} - - match: {test.settings: {index.number_of_shards: '1', index.number_of_replicas: '0'}} + - match: {test.settings: {index: {number_of_shards: '1', number_of_replicas: '0'}}} + --- "Get all templates": @@ -43,3 +44,13 @@ setup: local: true - is_true: test + +--- +"Get template with flat settings": + + - do: + indices.get_template: + name: test + flat_settings: true + + - match: {test.settings: {index.number_of_shards: '1', index.number_of_replicas: '0'}} diff --git a/rest-api-spec/test/indices.put_template/10_basic.yaml b/rest-api-spec/test/indices.put_template/10_basic.yaml index 129f8089acf..7d3e7103b10 100644 --- a/rest-api-spec/test/indices.put_template/10_basic.yaml +++ b/rest-api-spec/test/indices.put_template/10_basic.yaml @@ -12,6 +12,7 @@ - do: indices.get_template: name: test + flat_settings: true - match: {test.template: "test-*"} - match: {test.settings: {index.number_of_shards: '1', index.number_of_replicas: '0'}} @@ -54,6 +55,7 @@ - do: indices.get_template: name: test + flat_settings: true - match: {test.template: "test-*"} - match: {test.settings: {index.number_of_shards: '1', index.number_of_replicas: '0'}} diff --git a/src/main/java/org/elasticsearch/cluster/metadata/IndexTemplateMetaData.java b/src/main/java/org/elasticsearch/cluster/metadata/IndexTemplateMetaData.java index 243dfcc8a38..0267facaed5 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/IndexTemplateMetaData.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/IndexTemplateMetaData.java @@ -275,9 +275,7 @@ public class IndexTemplateMetaData { builder.field("template", indexTemplateMetaData.template()); builder.startObject("settings"); - for (Map.Entry entry : indexTemplateMetaData.settings().getAsMap().entrySet()) { - builder.field(entry.getKey(), entry.getValue()); - } + indexTemplateMetaData.settings().toXContent(builder, params); builder.endObject(); if (params.paramAsBoolean("reduce_mappings", false)) {