ElasticSearch创build索引types错误

我正在使用elasticsearch npm模块。 创build索引会导致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'); }); 

根据索引创build文档 ,我应该能够传递一个string与索引的名称。 我很困惑,为什么它一般是失败的,为什么错误信息是指一条path。

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'); });