Delete Document API
The Delete API allows to delete 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/1
The result of the above get operation is a 204 No Content
HTTP response code
with no body.
DELETE /twitter/tweet/1
is not the same as DELETE /twitter/tweet/1/
, the
former will delete document 1
inside index /twitter/tweet/
and the later
will delete the whole index /twitter/tweet/1/
.
Trailing slashes are important.
Commit
By passing commit
query param to the request, you can ensure the operation
returns once the document changes have been committed to the primary shard.
Try limiting the use of commit
as it will hit performance.
Optimistic Concurrency Control
Delete operations can be made optional and only be performed if the last
current document version matches the passed version
in the query param. If a
mismatch is detected, the operation will result in a 409 Conflict
HTTP response
code. See Versioning for more details.