Bird
Raised Fist0

Why does this query fail?

medium📝 Debug Q7 of Q15
Elasticsearch - Advanced Patterns
Why does this query fail?
{"sort": [{"date": "asc"}, {"_id": "asc"}], "size": 5, "search_after": ["2023-01-01T00:00:00"]}
Asearch_after array length does not match number of sort fields
BUsing _id in sort is not allowed with search_after
CSize must be 1 when using multiple sort fields
DDate format is invalid for search_after
Step-by-Step Solution
Solution:
  1. Step 1: Count sort fields and search_after values

    There are two sort fields but only one value in search_after array, causing mismatch.

  2. Step 2: Validate other options

    Using _id is allowed, size can be any positive integer, and date format is valid ISO string.

  3. Final Answer:

    search_after array length does not match number of sort fields -> Option A
  4. Quick Check:

    search_after length = sort fields count [OK]
Quick Trick: search_after array must match sort fields count exactly [OK]
Common Mistakes:
MISTAKES
  • Providing fewer search_after values than sort fields
  • Assuming _id cannot be sorted with search_after

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes