allow index settings to be passed on index creation
This commit is contained in:
@@ -22,10 +22,12 @@ const schema = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function createIndex(client, indexName, doctype = defaultSettings.DEFAULT_SETTING_DOCTYPE) {
|
export default function createIndex(client, indexName, doctype = defaultSettings.DEFAULT_SETTING_DOCTYPE, settings = {}) {
|
||||||
const indexBody = { mappings : {} };
|
const indexBody = { mappings : {} };
|
||||||
indexBody.mappings[doctype] = { properties: schema };
|
indexBody.mappings[doctype] = { properties: schema };
|
||||||
|
|
||||||
|
const body = Object.assign({}, { settings }, indexBody);
|
||||||
|
|
||||||
return client.indices.exists({
|
return client.indices.exists({
|
||||||
index: indexName,
|
index: indexName,
|
||||||
})
|
})
|
||||||
@@ -34,7 +36,7 @@ export default function createIndex(client, indexName, doctype = defaultSettings
|
|||||||
return client.indices.create({
|
return client.indices.create({
|
||||||
ignore: 400,
|
ignore: 400,
|
||||||
index: indexName,
|
index: indexName,
|
||||||
body: indexBody
|
body: body
|
||||||
})
|
})
|
||||||
.then(() => true);
|
.then(() => true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user