我需要使用elasticsearch.js Node 模块列出我的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 的正确语法是什么,它会列出所有可用的索引?
最佳答案
尝试这样
const indices = await client.cat.indices({format: 'json'})
console.log('indices:', indices)
否则
client.cat.indices("b",function(r,q){
console.log(r,q);
}) }]);
希望有帮助。
关于node.js - 如何使用elasticsearch.js客户端列出所有索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57996876/