Assuming the documents have prices: 10, 25, 7, 30, 15.
medium
A. 25
B. 30
C. 15
D. 10
Solution
Step 1: Understand max aggregation
The max aggregation returns the highest value of the specified field.
Step 2: Identify the maximum price from the list
From the prices 10, 25, 7, 30, 15, the maximum is 30.
Final Answer:
30 -> Option B
Quick Check:
max price = 30 [OK]
Hint: max returns the highest number in the field values [OK]
Common Mistakes:
Choosing the second highest value instead of max
Confusing max with avg or sum
Ignoring the actual field values
4. Identify the error in this Elasticsearch aggregation query that tries to calculate the minimum value of the field age:
{
"aggs": {
"min_age": {
"min": "age"
}
}
}
medium
A. The query is missing a "query" section
B. The aggregation name "min_age" is invalid
C. The aggregation type should be "max" instead of "min"
D. The field name should be inside a nested object with key "field"
Solution
Step 1: Check the syntax for min aggregation
The min aggregation requires the field name inside an object with key "field".
Step 2: Identify the error in the given query
The query uses "min": "age" instead of "min": { "field": "age" } which is incorrect syntax.
Final Answer:
The field name should be inside a nested object with key "field" -> Option D
Quick Check:
min aggregation needs "field": "age" [OK]
Hint: Field must be inside { "field": "name" } for metric aggs [OK]
Common Mistakes:
Passing field name as string directly without object
Confusing aggregation type names
Assuming query section is mandatory for aggregation
5. You want to find the average, sum, minimum, and maximum values of the field score using the avg, sum, min, and max aggregations in a single Elasticsearch query. Which aggregation structure correctly achieves this?