ElasticSearch 创建索引类型错误
ElasticSearch Create Index TypeError
我正在使用 elasticsearch npm 模块。创建索引会导致 TypeError,其消息为:
Unable to build a path with those params. Supply at least index
我使用的代码如下所示:
var client = new elasticsearch.Client({
host: 'localhost:9200',
log: 'trace'
});
client.indices.create('myindex', function (err, resp) {
if (err)
console.log('failed to create ElasticSearch index, ' + err.message);
else
console.log('successfully created ElasticSearch index');
});
根据index create docs,我应该可以传递一个带有索引名称的字符串。我很困惑为什么它通常会失败,以及为什么错误消息指的是路径。
create()
的第一个参数需要是字典。尝试:
client.indices.create({index: 'myindex'}, function (err, resp) {
if (err)
console.log('failed to create ElasticSearch index, ' + err.message);
else
console.log('successfully created ElasticSearch index');
});
我正在使用 elasticsearch npm 模块。创建索引会导致 TypeError,其消息为:
Unable to build a path with those params. Supply at least index
我使用的代码如下所示:
var client = new elasticsearch.Client({
host: 'localhost:9200',
log: 'trace'
});
client.indices.create('myindex', function (err, resp) {
if (err)
console.log('failed to create ElasticSearch index, ' + err.message);
else
console.log('successfully created ElasticSearch index');
});
根据index create docs,我应该可以传递一个带有索引名称的字符串。我很困惑为什么它通常会失败,以及为什么错误消息指的是路径。
create()
的第一个参数需要是字典。尝试:
client.indices.create({index: 'myindex'}, function (err, resp) {
if (err)
console.log('failed to create ElasticSearch index, ' + err.message);
else
console.log('successfully created ElasticSearch index');
});