Bird
0
0

Which of the following is the correct syntax to sort results by the field price in descending order?

easy📝 Syntax Q12 of 15
Elasticsearch - Search Results and Scoring
Which of the following is the correct syntax to sort results by the field price in descending order?
A"sort": [{"price": "desc"}]
B"sort": {"price": "descending"}
C"sort": ["price:desc"]
D"sort": [{"price": "down"}]
Step-by-Step Solution
Solution:
  1. Step 1: Check Elasticsearch sort syntax

    Sorting uses an array of objects with field name and order as "asc" or "desc" strings.
  2. Step 2: Validate each option

    "sort": [{"price": "desc"}] uses correct JSON array and "desc" keyword. Others use invalid keywords or formats.
  3. Final Answer:

    "sort": [{"price": "desc"}] -> Option A
  4. Quick Check:

    Correct syntax uses array and "desc" [OK]
Quick Trick: Use array with field and "asc" or "desc" strings [OK]
Common Mistakes:
MISTAKES
  • Using wrong keywords like "descending" or "down"
  • Not using an array for sort
  • Incorrect JSON object structure

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes