简体   繁体   中英

How to list ALL indices using elasticsearch.js client

I need to list all indices in my node.js app, using elasticsearch.js node module. What I have is:

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

  client.indices.get({

  })

The error I get is:

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

What is the proper syntax for client.indices.get, which would list all available indices?

Try like this

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

or else

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

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM