0
0
Elasticsearchquery~20 mins

Scroll API for deep pagination in Elasticsearch - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Scroll API Mastery
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 Scroll API request?

Given the following Elasticsearch Scroll API request snippet, what will be the value of hits.total.value in the first scroll response?

Elasticsearch
{
  "size": 2,
  "query": { "match_all": {} }
}

POST /my_index/_search?scroll=1m

Response snippet:
{
  "_scroll_id": "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAA...",
  "hits": {
    "total": {"value": 5, "relation": "eq"},
    "hits": [
      {"_id": "1", "_source": {"field": "value1"}},
      {"_id": "2", "_source": {"field": "value2"}}
    ]
  }
}
A5
B2
C0
Dundefined
Attempts:
2 left
💡 Hint

The total number of matching documents is returned in hits.total.value, not the number of hits in the current batch.

🧠 Conceptual
intermediate
2:00remaining
Why use Scroll API instead of from/size for deep pagination?

Which of the following is the main reason to use the Scroll API for deep pagination in Elasticsearch instead of using from and size parameters?

AScroll API allows updating documents during pagination.
BScroll API automatically sorts results by relevance score.
CScroll API is faster and more efficient for retrieving large numbers of documents sequentially.
DScroll API caches all results in memory permanently.
Attempts:
2 left
💡 Hint

Think about performance when retrieving many documents beyond the first few pages.

🔧 Debug
advanced
2:00remaining
Identify the error in this Scroll API usage

What error will occur when running the following sequence of Elasticsearch Scroll API calls?

Elasticsearch
POST /my_index/_search?scroll=1m
{
  "size": 3,
  "query": { "match_all": {} }
}

POST /_search/scroll
{
  "scroll": "1m",
  "scroll_id": "incorrect_scroll_id"
}
A404 Not Found error because the scroll ID is invalid or expired.
BNo error; the scroll returns the next batch of results.
CTimeout error because the scroll duration is too short.
DSyntaxError due to malformed JSON in the scroll request.
Attempts:
2 left
💡 Hint

Consider what happens if you provide a wrong or expired scroll ID.

📝 Syntax
advanced
2:00remaining
Which Scroll API request syntax is correct?

Choose the correct syntax for requesting the next batch of results using the Scroll API.

A
POST /my_index/_search/scroll
{
  "scroll_id": "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAA..."
}
B
POST /_search/scroll
{
  "scroll": "2m",
  "scroll_id": "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAA..."
}
CGET /_search/scroll?scroll=2m&scroll_id=DXF1ZXJ5QW5kRmV0Y2gBAAAAAAA...
D
POST /_search/scroll
{
  "scroll_id": "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAA...",
  "timeout": "2m"
}
Attempts:
2 left
💡 Hint

Check the official Scroll API syntax for the request body and HTTP method.

🚀 Application
expert
2:00remaining
How many documents are retrieved after 3 scroll requests?

You run a Scroll API search with size set to 4 on an index with 10 matching documents. You perform 3 scroll requests (initial search + 2 scrolls). How many documents have you retrieved in total?

A6
B8
C12
D10
Attempts:
2 left
💡 Hint

Multiply the batch size by the number of scroll requests, but consider the total documents available.