我正在使用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,我应该能够传递一个带有索引名称的字符串。我很困惑为什么它一般会失败,以及为什么错误消息指的是路径。
答案 0 :(得分:2)
create()
的第一个参数需要是dict。尝试:
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');
});