Delete by Query API is very similar to update by query but can be used to delete the documents that match the query. It works by taking a snapshot of the index and deleting the documents. Between taking the snapshot and executing the delete query, if the documents are modified, the operation fails due to the version conflict. To proceed on failures, conflicts=proceed can be specified as a URL parameter, and any failures that occur are reported in the response. For example, to delete all the documents that contain the word shirt, the query is as follows:
POST chapter5/_delete_by_query?conflicts=proceed { "query": { "match": { "product_name": "shirt" } } }
The response to the preceding query is shown here:
{ "took": 5, "timed_out": ...