0
0
Elasticsearchquery~20 mins

Retrieving a document by ID in Elasticsearch - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Elasticsearch Document Retrieval 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 Elasticsearch GET request?
Given the following Elasticsearch GET request to retrieve a document by ID, what will the response be?
Elasticsearch
GET /library/_doc/123
A{"_index": "library", "_id": "123", "found": true, "_source": {"title": "Learn Elasticsearch", "author": "Jane Doe"}}
B{"error": "document missing"}
C{"_id": "123", "found": false}
D{"title": "Learn Elasticsearch", "author": "Jane Doe"}
Attempts:
2 left
💡 Hint
The GET request returns a JSON object with metadata and the document source inside the _source field.
🧠 Conceptual
intermediate
1:00remaining
Which HTTP method is used to retrieve a document by ID in Elasticsearch?
You want to get a document from Elasticsearch by its ID. Which HTTP method should you use?
APOST
BGET
CPUT
DDELETE
Attempts:
2 left
💡 Hint
Think about which HTTP method is used to fetch data without changing it.
🔧 Debug
advanced
1:30remaining
Why does this Elasticsearch GET request return a 404 error?
You run this request: GET /books/_doc/999 But you get a 404 error. What is the most likely reason?
AThe HTTP method GET is not supported for document retrieval.
BThe index name 'books' is misspelled and does not exist.
CThe document with ID 999 does not exist in the 'books' index.
DThe request body is missing.
Attempts:
2 left
💡 Hint
A 404 error means the resource was not found.
📝 Syntax
advanced
1:30remaining
Which of these is the correct syntax to retrieve a document by ID in Elasticsearch?
Choose the correct Elasticsearch GET request syntax to retrieve a document with ID 'abc123' from the index 'products'.
AGET /products/_doc/abc123
BGET /products/_search/abc123
CPOST /products/_doc/abc123
DGET /products/doc/abc123
Attempts:
2 left
💡 Hint
The correct path includes the index, the type '_doc', and the document ID.
🚀 Application
expert
2:30remaining
How to retrieve multiple documents by ID in a single Elasticsearch request?
You want to get documents with IDs '1', '2', and '3' from the 'users' index in one request. Which Elasticsearch API and request body should you use?
ASend three separate GET requests for each ID.
BUse the GET API with a comma-separated list: GET /users/_doc/1,2,3
CUse the _search API with a query matching the IDs.
DUse the _mget API with a JSON body listing the IDs.
Attempts:
2 left
💡 Hint
Elasticsearch has a special API for multiple document retrieval by IDs.