我正在使用elasticsearch npm 模块。创建索引会导致类型错误,其消息为:
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');
});
关于javascript - ElasticSearch 创建索引类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28160906/