使用 NodeJS 客户端检索弹性搜索的 GET /stats

Retrieving GET /stats of Elastic search using NodeJS client

我可以使用 kibana 在我的本地环境中轻松获得此 elasticsearch 命令 (GET /_stats) 响应。但是,我需要 运行 node.js 服务器上的命令。 我尝试了以下但它不起作用,而是抛出错误。谁能帮我解决这个问题?

const client = new Client({
 node: process.env.ES_URL,
 auth: {
 username: process.env.ES_USER,
 password: process.env.ES_PASSWORD,
  },
});
const stats = await client.stats();
...
//The error response is TypeError: client.stats is not a function

PS:使用此命令 returns 在 Kibana (GET _cluster/health) 上得到相同的结果

const {body} = await client.cluster.health({});

您尝试过 client.cluster.stats() 吗?