2

我需要使用 elasticsearch.js 节点模块列出我的 node.js 应用程序中的所有索引。我所拥有的是:

var elasticsearch = require('elasticsearch');
var client = new elasticsearch.Client({
  host: 'localhost:9200',
  log: 'trace'
});

  client.indices.get({

  })

我得到的错误是:

(node:72002) UnhandledPromiseRejectionWarning: TypeError: Unable to build a path with those params. Supply at least index

列出所有可用索引的 client.indices.get 的正确语法是什么?

4

1 回答 1

3

像这样试试

const indices = await client.cat.indices({format: 'json'})
console.log('indices:', indices)

要不然

client.cat.indices("b",function(r,q){
  console.log(r,q);
}) }]);

希望能帮助到你。

于 2019-09-18T16:20:41.190 回答