[[delete-doc]] === Deleting a Document
The syntax for deleting a document((("documents", "deleting"))) follows the same pattern that we have seen
already, but ((("DELETE method", "deleting documents")))((("HTTP methods", "DELETE")))uses the DELETE
method :
// SENSE: 030_Data/35_Delete_doc.json
If the document is found, Elasticsearch will return an HTTP response code
of 200 OK
and a response body like the following. Note that the _version
number has been incremented:
{ "found" : true, "_index" : "website", "_type" : "blog", "_id" : "123", "_version" : 3
If the document isn't((("version number (documents)", "incremented for document not found"))) found, we get a 404 Not Found
response code and
a body like this:
{ "found" : false, "_index" : "website", "_type" : "blog", "_id" : "123", "_version" : 4
Even though the document doesn't exist (found
is false
), the
_version
number has still been incremented. This is part of the internal
bookkeeping, which ensures that changes are applied in the correct order
across multiple nodes.
NOTE: As already mentioned in <