The documentation recommends the following function to delete a specific index:
client.delete({
index: 'myindex',
type: 'mytype',
id: '1'
}, function (error, response) {
// ...
});
Which I have adapted to:
client.delete({
index: '_all'
}, function (error, response) {
// ...
});
But that gives me the following error:
Unable to build a path with those params. Supply at least index, type, id
I've been searching around for a couple of hours to no avail, anyone have any ideas?
To delete all indices, use _all or * . To disallow the deletion of indices with _all or wildcard expressions, set the action. destructive_requires_name cluster setting to true .
How to Delete an Index? Once you have the index you wish to remove from Elasticsearch, use the DELETE request followed by the index name.
If you no longer need an index, you can use the delete index API operation to delete it.
So, turns out I was using the wrong method. The below should take care of deleting all the indexes.
client.indices.delete({
index: '_all'
}, function(err, res) {
if (err) {
console.error(err.message);
} else {
console.log('Indexes have been deleted!');
}
});
You can introduce specific index names within that 'index' parameter, and you can also use '*' as an alternate to '_all'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With