Recall & Review
beginner
What is a range query in Elasticsearch?
A range query finds documents where a field's value falls within a specified range, like numbers, dates, or strings.
Click to reveal answer
beginner
Which operators can you use in a range query?
You can use
gt (greater than), gte (greater than or equal), lt (less than), and lte (less than or equal).Click to reveal answer
beginner
Show a simple example of a range query to find documents with
age between 20 and 30.{
"query": {
"range": {
"age": {
"gte": 20,
"lte": 30
}
}
}
}Click to reveal answer
beginner
Can range queries be used on date fields in Elasticsearch?
Yes! Range queries work well on date fields to find documents within specific time periods.
Click to reveal answer
beginner
What happens if you use only one operator in a range query, like
gt?The query finds all documents where the field's value is greater than the given value, with no upper limit.
Click to reveal answer
Which operator finds documents with values less than or equal to a number?
✗ Incorrect
The
lte operator means 'less than or equal to'.What does this range query do? { "range": { "price": { "gt": 100 } } }
✗ Incorrect
The
gt operator means 'greater than', so it finds prices above 100.Can range queries be used on text fields?
✗ Incorrect
Range queries work on keyword fields (exact values), not on analyzed text fields.
Which operator includes the boundary value in the range?
✗ Incorrect
gte means 'greater than or equal to', so it includes the boundary.What is the result if you omit all operators in a range query?
✗ Incorrect
A range query needs at least one operator; otherwise, it is invalid and causes an error.
Explain how to use a range query to find documents with a date field between two dates.
Think about how to specify start and end dates with operators.
You got /4 concepts.
Describe the difference between the operators gt and gte in a range query.
Focus on whether the boundary value is included or not.
You got /3 concepts.