The CreateIndexCommand class is used for creating new indexes on ElasticSearch server.
Command ← IndexCommand ← CreateIndexCommand
PUT /<index>
- constructor(index, settings, params) - Initializes new instance of command.
- execute(client) - Executes this command.
- getSettings() - Returns settings of index.
- setSettings(settings) - Sets settings of index.
Methods inherited from IndexCommand
- getIndex() - Returns name of index.
- setIndex(index) - Sets name of index.
Methods inherited from Command
- getParameter(name) - Returns value of the specified parameter.
- setParameter(name, value) - Sets value of the specified parameter.
var elastic = require("elastic");
var client = new elastic.Client({/*options*/});
var settings = {
"index": {
"number_of_shards" : 12,
"number_of_replicas" : 2
}
};
var cmd = new elastic.CreateIndexCommand("test");
cmd.setSettings(settings);
cmd.execute(client).then(function (result) {
console.log(JSON.stringify(result, null, " "));
});{
"acknowledged": true
}constructor([index: string, [settings: object, [params: object]]])
execute(client: Client): Promise
getSettings(): object|null
setSettings(settings: object)