WARNING: Version 1.4 of Elasticsearch has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Deleting Documents
editDeleting Documents
editDeleting a document is fairly straightforward. This example shows how to delete our previous customer with the ID of 2:
curl -XDELETE 'localhost:9200/customer/external/2?pretty'
We also have the ability to delete multiple documents that match a query condition. This example shows how to delete all customers whose names contain "John":
curl -XDELETE 'localhost:9200/customer/external/_query?pretty' -d ' { "query": { "match": { "name": "John" } } }'
Note above that the URI has changed to /_query
to signify a delete-by-query API with the delete query criteria in the body, but we are still using the DELETE verb. Don’t worry yet about the query syntax as we will cover that later in this tutorial.