Bird
0
0

Identify the error in this Elasticsearch sort snippet:

medium📝 Debug Q14 of 15
Elasticsearch - Search Results and Scoring
Identify the error in this Elasticsearch sort snippet:
{
  "sort": {"date": "asc"}
}
ASort cannot be used with date fields.
BSort must be an array, not a single object.
CField name "date" must be inside quotes.
DThe order "asc" is invalid; should be "ascending".
Step-by-Step Solution
Solution:
  1. Step 1: Check the required structure for sort

    Sort expects an array of objects, even if sorting by one field.
  2. Step 2: Analyze the given snippet

    The snippet uses an object directly, missing the array brackets [].
  3. Final Answer:

    Sort must be an array, not a single object. -> Option B
  4. Quick Check:

    Sort = array of objects [OK]
Quick Trick: Sort always uses an array, even for one field [OK]
Common Mistakes:
MISTAKES
  • Using object instead of array for sort
  • Wrong order keywords like "ascending"
  • Thinking sort can't be used on dates

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes