REST Create Index: Not taking JSON index settings into account unless wrapped in settings.
This commit is contained in:
parent
d8aef57baa
commit
c8bfa455ad
|
@ -61,15 +61,22 @@ public class RestCreateIndexAction extends BaseRestHandler {
|
|||
try {
|
||||
Map<String, Object> source = XContentFactory.xContent(xContentType)
|
||||
.createParser(request.contentByteArray(), request.contentByteArrayOffset(), request.contentLength()).mapAndClose();
|
||||
boolean found = false;
|
||||
if (source.containsKey("settings")) {
|
||||
createIndexRequest.settings((Map<String, Object>) source.get("settings"));
|
||||
found = true;
|
||||
}
|
||||
if (source.containsKey("mappings")) {
|
||||
found = true;
|
||||
Map<String, Object> mappings = (Map<String, Object>) source.get("mappings");
|
||||
for (Map.Entry<String, Object> entry : mappings.entrySet()) {
|
||||
createIndexRequest.mapping(entry.getKey(), (Map<String, Object>) entry.getValue());
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
// the top level are settings, use them
|
||||
createIndexRequest.settings(source);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
channel.sendResponse(new XContentThrowableRestResponse(request, e));
|
||||
|
|
Loading…
Reference in New Issue