Skip to content

Latest commit

 

History

History
52 lines (42 loc) · 1.68 KB

35_Delete.asciidoc

File metadata and controls

52 lines (42 loc) · 1.68 KB

Deleting a Document

The syntax for deleting a document follows the same pattern that we have seen already, but uses the DELETE method :

DELETE /website/blog/123

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 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 [update-doc], deleting a document doesn’t immediately remove the document from disk; it just marks it as deleted. Elasticsearch will clean up deleted documents in the background as you continue to index more data.