I want to perform a delete-by-query
, specifically delete all documents that have a field Kname that contains Gary
. I am using the latest version of elasticsearch (2.3) I am using the official ES client:
elasticsearch-js
How can I perform such a deletion? Is it not supported? If not, appreciate any code/alternatives.
Since you are on ES 2.x, delete-by-query is now a plugin, so you need to install it first and then also require the deleteByQuery extension library for the Javascript client.
Then you can perform
client.deleteByQuery({
index: 'test',
type: 'something',
body: {
query: {
match: { Kname: 'gary' }
}
}
}, function (error, response) {
console.log(response);
});
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