Challenge - 5 Problems
Range Query Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a basic range query
What is the expected output count of documents matching this Elasticsearch range query on a field
age with values from 20 to 30 inclusive?Elasticsearch
{
"query": {
"range": {
"age": {
"gte": 20,
"lte": 30
}
}
}
}Attempts:
2 left
💡 Hint
Remember that gte means 'greater than or equal' and lte means 'less than or equal'.
✗ Incorrect
The range query with gte: 20 and lte: 30 selects documents where the age field is between 20 and 30, including both 20 and 30.
❓ Predict Output
intermediate2:00remaining
Range query with date format
What documents will match this Elasticsearch range query on a
date field?Elasticsearch
{
"query": {
"range": {
"date": {
"gte": "2023-01-01",
"lt": "2023-02-01",
"format": "yyyy-MM-dd"
}
}
}
}Attempts:
2 left
💡 Hint
lt means less than, so the upper bound excludes the date specified.
✗ Incorrect
The query selects documents with date greater than or equal to 2023-01-01 and less than 2023-02-01, so it includes all dates in January 2023 but excludes February 1.
🔧 Debug
advanced2:00remaining
Identify the error in this range query
What error will this Elasticsearch range query produce?
Elasticsearch
{
"query": {
"range": {
"price": {
"gte": 100,
"lte": 200
}
}
}
}Attempts:
2 left
💡 Hint
Check the JSON syntax carefully between the keys.
✗ Incorrect
The JSON is invalid because there is no comma between the gte and lte keys, causing a syntax error.
🧠 Conceptual
advanced2:00remaining
Effect of using only lt in a range query
What documents will match this Elasticsearch range query on a field
score?Elasticsearch
{
"query": {
"range": {
"score": {
"lt": 50
}
}
}
}Attempts:
2 left
💡 Hint
lt means strictly less than the value.
✗ Incorrect
The query matches documents where the score field is strictly less than 50, excluding 50 itself.
🚀 Application
expert3:00remaining
Construct a range query for exclusive bounds
Which Elasticsearch range query matches documents with
temperature strictly greater than 10 and strictly less than 20?Attempts:
2 left
💡 Hint
Use gt and lt for exclusive bounds.
✗ Incorrect
Using gt: 10 and lt: 20 matches values strictly greater than 10 and strictly less than 20, excluding 10 and 20.