Challenge - 5 Problems
Filter Aggregation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a simple filter aggregation
What is the output of this Elasticsearch aggregation query when run on an index with documents having a field
status with values active and inactive?Elasticsearch
{
"size": 0,
"aggs": {
"active_users": {
"filter": {
"term": { "status": "active" }
}
}
}
}Attempts:
2 left
💡 Hint
The filter aggregation counts documents matching the filter condition.
✗ Incorrect
The filter aggregation returns the count of documents matching the filter. Here, it counts documents where status is 'active'.
🧠 Conceptual
intermediate1:30remaining
Purpose of filter aggregation in Elasticsearch
What is the main purpose of using a filter aggregation in Elasticsearch?
Attempts:
2 left
💡 Hint
Filter aggregation isolates documents matching a condition for aggregation.
✗ Incorrect
Filter aggregation lets you count or aggregate only documents matching a filter, without changing the overall query results.
🔧 Debug
advanced2:00remaining
Identify the error in this filter aggregation query
This filter aggregation query is intended to count documents where
age is greater than 30. What error will Elasticsearch return?Elasticsearch
{
"size": 0,
"aggs": {
"older_than_30": {
"filter": {
"range": {
"age": { "gt": 30 }
}
}
}
}
}Attempts:
2 left
💡 Hint
Check the syntax of the range filter.
✗ Incorrect
The query uses a valid range filter with 'gt' operator inside the filter aggregation, so it runs without error.
❓ Predict Output
advanced2:30remaining
Output of nested filter aggregations
Given this aggregation query, what is the value of
doc_count for active_and_premium?Elasticsearch
{
"size": 0,
"aggs": {
"active_users": {
"filter": { "term": { "status": "active" } },
"aggs": {
"active_and_premium": {
"filter": { "term": { "subscription": "premium" } }
}
}
}
}
}Attempts:
2 left
💡 Hint
The inner filter counts documents that are both active and premium.
✗ Incorrect
The outer filter selects active users (5 docs), the inner filter counts how many of those have premium subscription (3 docs).
📝 Syntax
expert2:00remaining
Which option causes a syntax error in filter aggregation?
Which of these filter aggregation snippets will cause a syntax error when run in Elasticsearch?
Attempts:
2 left
💡 Hint
Look for missing punctuation in JSON syntax.
✗ Incorrect
Option D is missing a colon between "status" and "active", causing a JSON syntax error.