Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to calculate the average of the field "price".
Elasticsearch
{
"aggs": {
"average_price": {
"[1]": {
"field": "price"
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'sum' instead of 'avg' will calculate the total, not the average.
Using 'min' or 'max' will give the smallest or largest value, not the average.
✗ Incorrect
The avg aggregation calculates the average value of a numeric field.
2fill in blank
mediumComplete the code to calculate the total sum of the field "quantity".
Elasticsearch
{
"aggs": {
"total_quantity": {
"[1]": {
"field": "quantity"
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'avg' will calculate the average, not the total sum.
Using 'min' or 'max' will return the smallest or largest value, not the sum.
✗ Incorrect
The sum aggregation adds up all values of the specified field.
3fill in blank
hardFix the error in the aggregation type to find the minimum value of "age".
Elasticsearch
{
"aggs": {
"youngest": {
"[1]": {
"field": "age"
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'max' will give the largest value, not the minimum.
Using 'sum' or 'avg' will not find the minimum value.
✗ Incorrect
The min aggregation finds the smallest value in the field.
4fill in blank
hardFill both blanks to calculate the maximum value of "score" and the average of "time".
Elasticsearch
{
"aggs": {
"max_score": {
"[1]": {
"field": "score"
}
},
"avg_time": {
"[2]": {
"field": "time"
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up 'min' and 'max' for the score aggregation.
Using 'sum' instead of 'avg' for the time aggregation.
✗ Incorrect
Use max to find the highest score and avg to find the average time.
5fill in blank
hardFill all three blanks to calculate the sum of "sales", the minimum of "discount", and the average of "rating".
Elasticsearch
{
"aggs": {
"total_sales": {
"[1]": {
"field": "sales"
}
},
"lowest_discount": {
"[2]": {
"field": "discount"
}
},
"average_rating": {
"[3]": {
"field": "rating"
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping 'min' and 'max' for discount.
Using 'max' instead of 'sum' for sales.
Using 'sum' instead of 'avg' for rating.
✗ Incorrect
Use sum for total sales, min for lowest discount, and avg for average rating.