Challenge - 5 Problems
Elasticsearch Indexing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the result of this indexing request?
Given the following Elasticsearch indexing request, what will be the status in the response if the document is successfully indexed?
Elasticsearch
POST /library/_doc/1 { "title": "Learn Elasticsearch", "author": "Jane Doe", "year": 2023 }
Attempts:
2 left
💡 Hint
When you use POST with a new document ID, Elasticsearch creates the document.
✗ Incorrect
Using POST with a new document ID creates the document, so the result field in the response is 'created'.
❓ Predict Output
intermediate2:00remaining
What happens when you PUT a document with an existing ID?
Consider this request to update a document by ID using PUT. What will the 'result' field show if the document already exists?
Elasticsearch
PUT /library/_doc/1 { "title": "Mastering Elasticsearch", "author": "Jane Doe", "year": 2024 }
Attempts:
2 left
💡 Hint
PUT with an existing ID replaces the document, so it updates.
✗ Incorrect
PUT with an existing document ID replaces the document, so the result is 'updated'.
🧠 Conceptual
advanced1:30remaining
Which HTTP method is idempotent for indexing documents?
In Elasticsearch, which HTTP method ensures that multiple identical requests have the same effect on the document store?
Attempts:
2 left
💡 Hint
Idempotent means the same request repeated does not change the result after the first time.
✗ Incorrect
PUT is idempotent because sending the same document with the same ID multiple times results in the same state.
❓ Predict Output
advanced2:00remaining
What error occurs if you try to index a document with invalid JSON?
What error will Elasticsearch return if you send this indexing request with malformed JSON?
Elasticsearch
POST /library/_doc
{
"title": "Invalid JSON",
"author": "John Doe",
"year": 2023
}Attempts:
2 left
💡 Hint
Malformed JSON causes a parsing error before indexing.
✗ Incorrect
Elasticsearch returns a json_parse_exception when the JSON is invalid.
🧠 Conceptual
expert2:30remaining
What is the difference in behavior between POST and PUT when indexing documents without specifying an ID?
In Elasticsearch, when you index a document without specifying an ID, what is the difference in behavior between using POST and PUT methods?
Attempts:
2 left
💡 Hint
Think about which method allows auto ID generation.
✗ Incorrect
POST allows auto-generation of document IDs when none is provided; PUT requires an explicit ID and will fail if missing.