Challenge - 5 Problems
Range Buckets Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a simple range bucket aggregation
What is the output of this Elasticsearch aggregation query on the field
price with the given buckets?Elasticsearch
{
"aggs": {
"price_ranges": {
"range": {
"field": "price",
"ranges": [
{ "to": 50 },
{ "from": 50, "to": 100 },
{ "from": 100 }
]
}
}
}
}Attempts:
2 left
💡 Hint
Look carefully at how documents are counted in each price range bucket.
✗ Incorrect
The aggregation divides documents into three buckets: prices less than 50, prices between 50 and 100, and prices 100 or more. The doc_count reflects how many documents fall into each range.
🧠 Conceptual
intermediate1:30remaining
Understanding range bucket keys
In Elasticsearch range bucket aggregations, what does the bucket key
"* - 100.0" represent?Attempts:
2 left
💡 Hint
The asterisk (*) means unbounded on one side.
✗ Incorrect
The key "* - 100.0" means the bucket includes all values less than 100, with no lower bound.
🔧 Debug
advanced2:00remaining
Identify the error in this range bucket aggregation
This aggregation query is intended to create two buckets: prices less than 20 and prices between 20 and 50. What error will Elasticsearch return?
Elasticsearch
{
"aggs": {
"price_ranges": {
"range": {
"field": "price",
"ranges": [
{ "to": 20 },
{ "from": 20, "to": 50 },
{ "from": 50, "to": 10 }
]
}
}
}
}Attempts:
2 left
💡 Hint
Check the order of from and to values in each range.
✗ Incorrect
The last range has "from": 50 and "to": 10, which is invalid because from must be less than to.
📝 Syntax
advanced1:30remaining
Which option correctly defines a range bucket aggregation with open-ended ranges?
Select the correct JSON snippet for an Elasticsearch range aggregation with these buckets: less than 30, 30 to 70, and greater than 70.
Attempts:
2 left
💡 Hint
Open-ended ranges omit either from or to.
✗ Incorrect
Option C correctly uses open-ended ranges: first bucket has only "to", last bucket has only "from".
🚀 Application
expert3:00remaining
Calculate total documents in overlapping range buckets
Given this range aggregation with overlapping buckets, what is the total number of documents counted across all buckets if the index has 10 documents with these price values: [10, 25, 40, 55, 60, 75, 80, 90, 110, 130]?
Aggregation:
{
"aggs": {
"price_ranges": {
"range": {
"field": "price",
"ranges": [
{ "to": 50 },
{ "from": 30, "to": 70 },
{ "from": 60 }
]
}
}
}
}
Attempts:
2 left
💡 Hint
Count how many documents fall into each bucket, then sum all counts.
✗ Incorrect
The buckets overlap, so some documents are counted multiple times. Counting:
- to 50: 10, 25, 40 → 3 docs
- 30 to 70: 40, 55, 60 → 3 docs
- from 60: 60, 75, 80, 90, 110, 130 → 6 docs
Total = 3 + 3 + 6 = 12. But 60 is counted twice, so total is 3 + 3 + 6 = 12.
Wait, 60 is counted in both 30-70 and from 60 buckets.
Actually, 30 to 70 includes 40, 55, 60 (3 docs)
from 60 includes 60, 75, 80, 90, 110, 130 (6 docs)
to 50 includes 10, 25, 40 (3 docs)
Sum = 3 + 3 + 6 = 12
But 40 and 60 are counted twice.
The question asks total number of documents counted across all buckets (sum of doc_counts), so duplicates count.
So total is 3 + 3 + 6 = 12.
Option D is 13, so re-check.
Counting carefully:
- to 50: 10, 25, 40 → 3
- 30 to 70: 40, 55, 60 → 3
- from 60: 60, 75, 80, 90, 110, 130 → 6
Sum = 3 + 3 + 6 = 12
So correct answer is 12 (option D).
Correction: The correct answer is C.