elasticsearch-deletebyquery
Elasticsearch-js client extension for the Delete-by-query plugin.
This module provides the deleteByQuery
method which was removed from the core API in ES 2.0.0. For those with the Delete-by-query installed, this will bring back that feature to your Elasticsearch-js client.
Install the package.
npm install --save elasticsearch-deletebyquery
Then extend the Elasticsearch API by including this plugin.
'use strict';
const hosts = ['127.0.0.1'];
const apiVersion = '2.x';
const elasticsearch = require('elasticsearch');
const deleteByQuery = require('elasticsearch-deletebyquery');
const client = new elasticsearch.Client({
hosts, apiVersion,
plugins: [ deleteByQuery ]
});
Deleting documents with a simple query
client.deleteByQuery({
index: 'myindex',
q: 'test'
}, function (error, response) {
// ...
});
Deleting documents using the Query DSL
client.deleteByQuery({
index: 'posts',
body: {
query: {
term: { published: false }
}
}
}, function (error, response) {
// ...
});