1

I am using the official Elasticsearch Javascript client with version 6.0 and trying to delete a list of indices.

The code is:

const client = new elasticsearch.Client({
    "hosts": [
        "https://the-es-host-here.us-west-2.es.amazonaws.com"
    ],
    "apiVersion": "6.0",
    "sniffOnStart": true
});

const indices = [
    'enduser-2017-12-04',
    'enduser-2017-12-08',
    'enduser-2017-12-07',
    'enduser-2017-12-01',
    'enduser-2017-12-14',
    'enduser-2017-12-10',
    'enduser-2017-12-27',
    'enduser-2017-12-02',
    'enduser-2017-12-18',
    'enduser-2017-12-22',
    'enduser-2017-12-28',
    'enduser-2017-12-09',
    'enduser-2017-12-03',
    'enduser-2017-12-05',
    'enduser-2017-12-11',
    'enduser-2017-11-29',
    'enduser-2017-12-17',
    'enduser-2017-12-15',
    'enduser-2017-12-19'
];

client.indices.delete({
    index: indices
}, (error) => {
    if(error) {
        console.error(error);
    }
});

But none of the indexes are being deleted and I am seeing the following error:

Error: No Living connections

I don't see what I am doing wrong.

Justin
  • 42,716
  • 77
  • 201
  • 296
  • Does `curl "https://the-es-host-here.us-west-2.es.amazonaws.com"` return anything? To make sure that elasticsearch is running on the host. – Bless Jan 13 '18 at 09:50

1 Answers1

0

After an hour of fiddling the problem was related to passing "sniffOnStart": true into new elasticsearch.Client(). I have no idea why this breaks, but after removing sniffOnStart everything works.

Justin
  • 42,716
  • 77
  • 201
  • 296