From c8bfa455ad321319a50ce9ee4f58f175aa0230ff Mon Sep 17 00:00:00 2001 From: kimchy Date: Wed, 29 Dec 2010 12:10:51 +0200 Subject: [PATCH] REST Create Index: Not taking JSON index settings into account unless wrapped in settings. --- .../action/admin/indices/create/RestCreateIndexAction.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/admin/indices/create/RestCreateIndexAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/admin/indices/create/RestCreateIndexAction.java index 42c7a9cc150..82792420c75 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/admin/indices/create/RestCreateIndexAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/admin/indices/create/RestCreateIndexAction.java @@ -61,15 +61,22 @@ public class RestCreateIndexAction extends BaseRestHandler { try { Map source = XContentFactory.xContent(xContentType) .createParser(request.contentByteArray(), request.contentByteArrayOffset(), request.contentLength()).mapAndClose(); + boolean found = false; if (source.containsKey("settings")) { createIndexRequest.settings((Map) source.get("settings")); + found = true; } if (source.containsKey("mappings")) { + found = true; Map mappings = (Map) source.get("mappings"); for (Map.Entry entry : mappings.entrySet()) { createIndexRequest.mapping(entry.getKey(), (Map) entry.getValue()); } } + if (!found) { + // the top level are settings, use them + createIndexRequest.settings(source); + } } catch (Exception e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e));