Skip to content

Commit e2d66f4

Browse files
committed
REST Create Index: Not taking JSON index settings into account unless wrapped in settings.
1 parent 956e775 commit e2d66f4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/admin/indices/create/RestCreateIndexAction.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,22 @@ public class RestCreateIndexAction extends BaseRestHandler {
6161
try {
6262
Map<String, Object> source = XContentFactory.xContent(xContentType)
6363
.createParser(request.contentByteArray(), request.contentByteArrayOffset(), request.contentLength()).mapAndClose();
64+
boolean found = false;
6465
if (source.containsKey("settings")) {
6566
createIndexRequest.settings((Map<String, Object>) source.get("settings"));
67+
found = true;
6668
}
6769
if (source.containsKey("mappings")) {
70+
found = true;
6871
Map<String, Object> mappings = (Map<String, Object>) source.get("mappings");
6972
for (Map.Entry<String, Object> entry : mappings.entrySet()) {
7073
createIndexRequest.mapping(entry.getKey(), (Map<String, Object>) entry.getValue());
7174
}
7275
}
76+
if (!found) {
77+
// the top level are settings, use them
78+
createIndexRequest.settings(source);
79+
}
7380
} catch (Exception e) {
7481
try {
7582
channel.sendResponse(new XContentThrowableRestResponse(request, e));

0 commit comments

Comments
 (0)