Deleting a document
Deleting documents in Elasticsearch can be done in two ways: using the DELETE
call or the delete_by_query
call, which we'll look at in the next chapter.
Getting ready
You will need an up-and-running Elasticsearch installation, as we described in the Downloading and installing Elasticsearch recipe of Chapter 1, Getting Started.
To execute the commands in this recipe, you can use any HTTP client, such as curl (https://curl.haxx.se/), Postman (https://www.getpostman.com/), or others. I suggest using the Kibana console as it provides code completion and better character escaping for Elasticsearch.
To execute the following commands correctly, please use the indexed document from the Indexing a document recipe.
How to do it...
The REST API URL is the same as it is for GET
calls, but the HTTP method is DELETE
:
http://<server>/<index_name>/_doc/<id>
To delete a document, follow these steps:
- If we consider the
order
...