【问题标题】:How to list ALL indices using elasticsearch.js client如何使用 elasticsearch.js 客户端列出所有索引
【发布时间】:2020-01-19 15:41:15
【问题描述】:

我需要使用 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 的正确语法是什么,它将列出所有可用的索引?

【问题讨论】:

    标签: node.js elasticsearch elasticsearch.js


    【解决方案1】:

    这样试试

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

    否则

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

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-13
      • 2012-11-12
      • 1970-01-01
      • 2013-04-14
      • 1970-01-01
      • 2021-05-21
      • 1970-01-01
      相关资源
      最近更新 更多