From a547c1ccc09077eef99ced38f544d8b842e5e7cc Mon Sep 17 00:00:00 2001 From: kimchy Date: Wed, 16 Jun 2010 05:48:30 +0300 Subject: [PATCH] cluster state to return native json (if possible) as part of the mappings --- .../admin/cluster/state/RestClusterStateAction.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/admin/cluster/state/RestClusterStateAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/admin/cluster/state/RestClusterStateAction.java index 781e460a739..8ecaf21689a 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/admin/cluster/state/RestClusterStateAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/admin/cluster/state/RestClusterStateAction.java @@ -33,6 +33,8 @@ import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsFilter; +import org.elasticsearch.common.xcontent.XContentFactory; +import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.builder.XContentBuilder; import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.support.RestXContentBuilder; @@ -91,11 +93,14 @@ public class RestClusterStateAction extends BaseRestHandler { } builder.endObject(); - builder.startObject("mappings"); + builder.startArray("mappings"); for (Map.Entry entry : indexMetaData.mappings().entrySet()) { - builder.startObject(entry.getKey()).field("source", entry.getValue()).endObject(); + XContentParser parser = XContentFactory.xContent(entry.getValue()).createParser(entry.getValue()); + Map mapping = parser.map(); + parser.close(); + builder.map(mapping); } - builder.endObject(); + builder.endArray(); builder.endObject(); }