builder.field("template", templateMetaData.template());
builder.field("order", templateMetaData.order());
builder.startObject("settings");
Settings settings = settingsFilter.filterSettings(templateMetaData.settings());
for (Map.Entry<String, String> entry : settings.getAsMap().entrySet()) {
builder.field(entry.getKey(), entry.getValue());
}
builder.endObject();
builder.startObject("mappings");
for (Map.Entry<String, CompressedString> entry : templateMetaData.mappings().entrySet()) {
byte[] mappingSource = entry.getValue().uncompressed();
XContentParser parser = XContentFactory.xContent(mappingSource).createParser(mappingSource);
Map<String, Object> mapping = parser.map();
if (mapping.size() == 1 && mapping.containsKey(entry.getKey())) {
// the type name is the root value, reduce it
mapping = (Map<String, Object>) mapping.get(entry.getKey());
}
builder.field(entry.getKey());
builder.map(mapping);
}
builder.endObject();
builder.endObject();
}
builder.endObject();
builder.startObject("indices");
for (IndexMetaData indexMetaData : state.metaData()) {
builder.startObject(indexMetaData.index(), XContentBuilder.FieldCaseConversion.NONE);
builder.field("state", indexMetaData.state().toString().toLowerCase());
builder.startObject("settings");
Settings settings = settingsFilter.filterSettings(indexMetaData.settings());
for (Map.Entry<String, String> entry : settings.getAsMap().entrySet()) {
builder.field(entry.getKey(), entry.getValue());
}
builder.endObject();
builder.startObject("mappings");