Delete Document API
Edit pageThe Delete API deletes a document from a specific index based on its ID. The
following example deletes the document from an index called “twitter” with ID
1:
DELETE /twitter/tweet/1The result of the above delete operation is a 204 No Content HTTP response code
with no body. Deleting a document that is not there answers 404 Not Found.
A delete takes effect for the next search or get right away (reads see the writes of the node, see Visibility and Durability):
PUT /deleteapi/doc/1
{ "title": "to be deleted"}DELETE /deleteapi/doc/1GET /deleteapi/doc/1DELETE /deleteapi/doc/1Commit
Section titled “Commit”By passing the commit query param to the request, you can ensure the operation
returns once the delete has been committed to disk.
Version
Section titled “Version”A version query param makes the delete conditional: it applies only when the
document’s current version is that number, and otherwise answers 409 Conflict
and deletes nothing. The 409 body carries the current version as _version.
A version of 0 names a document that does not exist, so a delete with it
answers 404 (see Versioning).
PUT /deleteapi/doc/2
{ "title": "version 1"}DELETE /deleteapi/doc/2?version=99DELETE /deleteapi/doc/2?version=1Sources: src/server/search_views.cc (delete_document_view passes version
to delete_document) and docs/mechanisms/document-ids-and-versions.md.