0
0
Elasticsearchquery~20 mins

Deleting documents in Elasticsearch - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Elasticsearch Delete Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this delete request?

Given this Elasticsearch delete request, what is the expected response status?

Elasticsearch
DELETE /library/_doc/123
A{"result":"deleted"}
B{"result":"not_found"}
C{"error":"index_not_found_exception"}
D{"result":"updated"}
Attempts:
2 left
💡 Hint

If the document exists, deleting it returns a deleted result.

Predict Output
intermediate
2:00remaining
What happens if you delete a non-existing document?

What is the response when deleting a document that does not exist in the index?

Elasticsearch
DELETE /library/_doc/9999
A{"result":"deleted"}
B{"result":"created"}
C{"error":"document_missing_exception"}
D{"result":"not_found"}
Attempts:
2 left
💡 Hint

Deleting a non-existing document returns not_found in the result.

🔧 Debug
advanced
2:00remaining
Why does this delete request fail with an error?

Identify the error in this delete request and the cause of failure.

Elasticsearch
DELETE /library/_doc/
ASyntaxError: Missing document ID in the URL
BIndexNotFoundException: The index 'library' does not exist
CTypeError: Invalid HTTP method
DSuccess: Document deleted
Attempts:
2 left
💡 Hint

The delete API requires a document ID after the type.

🧠 Conceptual
advanced
2:00remaining
Which option correctly deletes documents matching a query?

Which Elasticsearch API call deletes all documents where status is obsolete?

APOST /library/_delete {"query": {"match_all": {}}}
BPOST /library/_delete_by_query {"query": {"term": {"status": "obsolete"}}}
CDELETE /library/_delete_by_query {"query": {"term": {"status": "obsolete"}}}
DDELETE /library/_doc/_query {"term": {"status": "obsolete"}}
Attempts:
2 left
💡 Hint

The _delete_by_query API deletes documents matching a query.

📝 Syntax
expert
2:00remaining
What error does this delete request produce?

What error results from this malformed delete request?

Elasticsearch
DELETE /library/_doc/123 {"query": {"match_all": {}}}
A500 Internal Server Error
B404 Not Found: Document does not exist
C400 Bad Request: Request body not allowed for DELETE on document API
D200 OK: Document deleted successfully
Attempts:
2 left
💡 Hint

The document delete API does not accept a request body.