0
0
Elasticsearchquery~5 mins

Range query in Elasticsearch - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Alt
Bgte
Clte
Dgt
What does this range query do? { "range": { "price": { "gt": 100 } } }
AFinds documents with price greater than 100
BFinds documents with price less than 100
CFinds documents with price equal to 100
DFinds documents with price between 0 and 100
Can range queries be used on text fields?
AYes, on any field
BOnly on keyword fields
CNo, only numeric and date fields
DOnly on analyzed text fields
Which operator includes the boundary value in the range?
Agt
Bnone
Clt
Dgte
What is the result if you omit all operators in a range query?
AIt causes an error
BIt returns all documents
CIt returns no documents
DIt defaults to gt:0
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.