0
0
Elasticsearchquery~10 mins

Retrieving a document by ID in Elasticsearch - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to retrieve a document by its ID using Elasticsearch's GET API.

Elasticsearch
GET /my_index/_doc/[1]
Drag options to blanks, or click blank then click option'
A123
Bindex
Cquery
Dsearch
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'search' or 'query' instead of the document ID.
Confusing the index name with the document ID.
2fill in blank
medium

Complete the JSON body to retrieve a document by ID using the Elasticsearch _search API with a term query.

Elasticsearch
{
  "query": {
    "term": { "_id": "[1]" }
  }
}
Drag options to blanks, or click blank then click option'
Aexists
Bmatch_all
Cuser_1
Drange
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'match_all' which returns all documents.
Using 'exists' or 'range' which are not for exact ID matching.
3fill in blank
hard

Fix the error in the code to correctly retrieve a document by ID using the Elasticsearch Python client.

Elasticsearch
response = client.get(index="products", id=[1])
Drag options to blanks, or click blank then click option'
Aabc123
B"abc123"
Cindex
Ddoc_id
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the ID without quotes causing a syntax error.
Using variable names that are not defined.
4fill in blank
hard

Fill both blanks to complete the curl command that retrieves a document by ID from Elasticsearch.

Elasticsearch
curl -X [1] "http://localhost:9200/[2]/_doc/42"
Drag options to blanks, or click blank then click option'
AGET
BPOST
Cmy_index
Dsearch
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST instead of GET.
Using 'search' instead of the index name.
5fill in blank
hard

Fill all three blanks to complete the Elasticsearch query that retrieves a document by ID using the REST API with a JSON body.

Elasticsearch
{
  "query": {
    "[1]": {
      "[2]": "[3]"
    }
  }
}
Drag options to blanks, or click blank then click option'
Aterm
B_id
Cdoc_789
Dmatch
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'match' instead of 'term' for exact ID matching.
Using a field other than '_id' to filter by document ID.