2

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?

Eugene Goldberg
  • 14,286
  • 20
  • 94
  • 167

1 Answers1

3

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.

Sathishkumar Rakkiyasamy
  • 3,509
  • 2
  • 30
  • 34