Bird
Raised Fist0

Given this Elasticsearch query snippet:

medium📝 Predict Output Q4 of Q15
Elasticsearch - Advanced Patterns
Given this Elasticsearch query snippet:
{"sort": [{"date": "asc"}], "size": 2, "search_after": ["2023-01-01T00:00:00"]}

What will the query return?
ADocuments including the date 2023-01-01
BDocuments sorted by date descending, starting before 2023-01-01
CDocuments sorted by date ascending, starting after 2023-01-01
DAn error because search_after value is invalid
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the sort and search_after values

    The sort is ascending by date, and search_after uses the last date value to start after that point.

  2. Step 2: Understand the effect of search_after

    The query returns documents with dates strictly greater than "2023-01-01T00:00:00", limited to 2 documents.

  3. Final Answer:

    Documents sorted by date ascending, starting after 2023-01-01 -> Option C
  4. Quick Check:

    search_after returns next page after given sort value [OK]
Quick Trick: search_after starts after given sort values, not including them [OK]
Common Mistakes:
MISTAKES
  • Assuming search_after includes the given value
  • Confusing ascending with descending sort

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes