Deleting by query
We saw how to delete a document in the Deleting a document recipe of Chapter 3, Basic Operations. Deleting a document is very quick, but it requires knowing the document ID for direct access and, in some cases, the routing value, too.
Elasticsearch provides a call to delete all of the documents that match a query using an additional module called re-index
, which is installed by default.
Getting ready
You will need an up-and-running Elasticsearch installation, as described in the Downloading and installing Elasticsearch recipe of Chapter 1, Getting Started.
To execute these commands, any HTTP client can be used, such as Curl (https://curl.haxx.se/), Postman (https://www.getpostman.com/), or similar. I suggest using the Kibana console as it provides code completion and better character escaping for Elasticsearch.
To correctly execute the following commands, you will need an index populated with the ch04/populate_kibana...