0
0
Elasticsearchquery~20 mins

Metric aggregations (avg, sum, min, max) in Elasticsearch - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Metric Aggregations Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this average aggregation?
Given the following Elasticsearch aggregation query, what is the average value returned for the field price?
Elasticsearch
{
  "size": 0,
  "aggs": {
    "average_price": {
      "avg": {
        "field": "price"
      }
    }
  }
}
A{"aggregations":{"average_price":{"value":25.5}}}
B{"aggregations":{"average_price":{"value":50}}}
C{"aggregations":{"average_price":{"value":0}}}
D{"aggregations":{"average_price":{"value":null}}}
Attempts:
2 left
💡 Hint
The average aggregation calculates the mean of all values in the price field.
Predict Output
intermediate
2:00remaining
What is the sum of the quantity field?
Consider this Elasticsearch aggregation query. What sum value will it return for the quantity field?
Elasticsearch
{
  "size": 0,
  "aggs": {
    "total_quantity": {
      "sum": {
        "field": "quantity"
      }
    }
  }
}
A{"aggregations":{"total_quantity":{"value":null}}}
B{"aggregations":{"total_quantity":{"value":100}}}
C{"aggregations":{"total_quantity":{"value":0}}}
D{"aggregations":{"total_quantity":{"value":50}}}
Attempts:
2 left
💡 Hint
Sum aggregation adds all values of the specified field.
Predict Output
advanced
2:00remaining
What is the minimum value returned by this aggregation?
Analyze this Elasticsearch aggregation query. What minimum value will it return for the rating field?
Elasticsearch
{
  "size": 0,
  "aggs": {
    "min_rating": {
      "min": {
        "field": "rating"
      }
    }
  }
}
A{"aggregations":{"min_rating":{"value":5}}}
B{"aggregations":{"min_rating":{"value":0}}}
C{"aggregations":{"min_rating":{"value":1}}}
D{"aggregations":{"min_rating":{"value":null}}}
Attempts:
2 left
💡 Hint
Minimum aggregation finds the smallest value in the field.
Predict Output
advanced
2:00remaining
What maximum value does this aggregation return?
Given this Elasticsearch aggregation query, what is the maximum value returned for the score field?
Elasticsearch
{
  "size": 0,
  "aggs": {
    "max_score": {
      "max": {
        "field": "score"
      }
    }
  }
}
A{"aggregations":{"max_score":{"value":99}}}
B{"aggregations":{"max_score":{"value":0}}}
C{"aggregations":{"max_score":{"value":null}}}
D{"aggregations":{"max_score":{"value":50}}}
Attempts:
2 left
💡 Hint
Maximum aggregation finds the largest value in the field.
🧠 Conceptual
expert
2:00remaining
Which aggregation returns null value and why?
In Elasticsearch, when running a metric aggregation like avg, sum, min, or max on a field that has no matching documents, what value is returned and why?
AThe aggregation returns the default value of the field type, like 0 for numbers.
BThe aggregation returns 0 because Elasticsearch assumes zero when no data is found.
CThe aggregation throws a runtime error indicating no data found.
DThe aggregation returns <code>null</code> because there are no documents to calculate the metric.
Attempts:
2 left
💡 Hint
Think about what happens when there is no data to aggregate.