Delete By Query Request
A DeleteByQueryRequest can be used to delete documents from an index. It requires an existing index (or a set of indices) on which deletion is to be performed.
The simplest form of a DeleteByQueryRequest looks like this and deletes all documents in an index:
DeleteByQueryRequest request =
new DeleteByQueryRequest("source1", "source2");
Creates the DeleteByQueryRequest on a set of indices.
By default version conflicts abort the DeleteByQueryRequest process but you can just count them with this:
request.setConflicts("proceed");
Set proceed on version conflict
You can limit the documents by adding a query.
request.setQuery(new TermQueryBuilder("user", "kimchy"));
Only copy documents which have field user set to kimchy
It’s also possible to limit the number of processed documents by