Deleting a document
Deleting a document can be performed by a command of the form DELETE {index-name}/{type}/{id}
, as shown here:
DELETE datalake/contacts/101
![](https://static.packt-cdn.com/products/9781787281349/graphics/Ch10-Fig31.png)
Figure 31: Query to Delete a Document
As seen earlier the result indicates a deleted document. The DELETE
in Elasticsearch is generally performed by id; however, deletion by query is also supported but it is a costlier operation. Again, the number of shards affected is 3 due to the same reason as stated earlier.
A point to remember here is that deletion does not reclaim the space immediately, till the deleted documents are expunged by the internal optimization/compaction processes.