0
0
Elasticsearchquery~10 mins

Search after for efficient pagination 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 add the search_after parameter for pagination.

Elasticsearch
{
  "query": { "match_all": {} },
  "sort": [ { "timestamp": "asc" } ],
  "size": 10,
  "search_after": [1]
}
Drag options to blanks, or click blank then click option'
A["2023-01-01T00:00:00"]
B"2023-01-01T00:00:00"
C10
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string instead of an array for search_after
Using a boolean or number instead of the sort values array
2fill in blank
medium

Complete the code to sort results by timestamp ascending and tie-break by _id.

Elasticsearch
{
  "sort": [
    { "timestamp": "asc" },
    { [1]: "asc" }
  ]
}
Drag options to blanks, or click blank then click option'
Adoc_count
B_score
Ctimestamp
D_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-unique fields for tie-break sorting
Using _score which is not stable for pagination
3fill in blank
hard

Fix the error in the search_after value format.

Elasticsearch
{
  "search_after": [1]
}
Drag options to blanks, or click blank then click option'
A{"timestamp": "2023-01-01T00:00:00", "_id": "abc123"}
B"2023-01-01T00:00:00, abc123"
C["2023-01-01T00:00:00", "abc123"]
D2023-01-01T00:00:00
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a string with comma-separated values
Passing an object instead of an array
4fill in blank
hard

Fill both blanks to create a search query with search_after and sort by timestamp and _id ascending.

Elasticsearch
{
  "query": { "match_all": {} },
  "sort": [
    { [1]: "asc" },
    { [2]: "asc" }
  ],
  "search_after": ["2023-01-01T00:00:00", "abc123"]
}
Drag options to blanks, or click blank then click option'
Atimestamp
B_score
C_id
Ddate
Attempts:
3 left
💡 Hint
Common Mistakes
Using _score instead of _id as tie-breaker
Using incorrect field names for sorting
5fill in blank
hard

Fill all three blanks to build a search query with match, sort, and search_after for pagination.

Elasticsearch
{
  "query": { "match": { "status": [1] } },
  "sort": [
    { [2]: "desc" },
    { [3]: "asc" }
  ],
  "search_after": [1680000000, "xyz789"]
}
Drag options to blanks, or click blank then click option'
A"active"
Btimestamp
C_id
Dstatus
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the match value string
Mixing up sort field order or directions
Using non-unique fields for tie-break sorting