0
0
Elasticsearchquery~5 mins

Deleting documents in Elasticsearch - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the basic way to delete a document in Elasticsearch?
You delete a document by specifying its index and ID using the DELETE API, like: <br>DELETE /index_name/_doc/document_id
Click to reveal answer
beginner
What happens if you try to delete a document that does not exist?
Elasticsearch returns a successful response with result: "not_found", meaning the document was not found but no error occurs.
Click to reveal answer
intermediate
How can you delete multiple documents matching a query?
Use the _delete_by_query API with a query to delete all documents matching that query in an index.
Click to reveal answer
intermediate
What is the difference between DELETE /index/_doc/id and POST /index/_delete_by_query?
DELETE /index/_doc/id deletes a single document by ID.<br>_delete_by_query deletes all documents matching a query, potentially many at once.
Click to reveal answer
intermediate
Why should you be careful when using _delete_by_query?
Because it can delete many documents at once, possibly more than intended, so always test your query carefully before running it.
Click to reveal answer
Which HTTP method is used to delete a single document by ID in Elasticsearch?
AGET
BPOST
CDELETE
DPUT
What does Elasticsearch return if you delete a document that does not exist?
Aresult: 'not_found'
BAn error
Cresult: 'deleted'
DNo response
Which API allows deleting multiple documents matching a query?
A_delete_all
B_bulk_delete
C_delete_by_id
D_delete_by_query
What is a key risk when using _delete_by_query?
AIt can delete more documents than intended
BIt cannot delete documents
CIt requires no query
DIt deletes only one document
How do you specify the document to delete in the DELETE API?
ABy query only
BBy index and document ID
CBy document content
DBy document size
Explain how to delete a single document in Elasticsearch and what happens if the document does not exist.
Think about the HTTP method and response.
You got /3 concepts.
    Describe the _delete_by_query API and why you should use it carefully.
    Consider bulk deletion and query safety.
    You got /3 concepts.