AI Hints
Home›Elasticsearch Tutorial›Exact Values and Ranges
Elasticsearch · Lesson 30 of 120

range

Between two values.

⏱ 2 min read▶ Video at 27:27🎓 Free
Watch this lesson in the Elasticsearch courseWatch on YouTube ↗Full Elasticsearch course

Price filters are everywhere. Under one hundred dollars. Between fifty and one fifty. Added this year. The range query handles numbers and dates.

  • Under $100
  • Between two values
  • Dates too

A price range

Range on price, with g t e fifty, and l t e one hundred. G t e means greater than or equal, and l t e means less than or equal. Run it. Every product priced from fifty to one hundred dollars.

Dev Tools Consoletext
GET products/_search?filter_path=hits.total.value,hits.hits._source.price
{
  "query": {
    "range": { "price": { "gte": 50, "lte": 100 } }
  },
  "size": 3
}
Output
{
  "hits": {
    "total": {"value": 11},
    "hits": [
      {"_source": {"price": 69.99}},
      {"_source": {"price": 57.99}},
      {"_source": {"price": 53.99}}
    ]
  }
}
Also uses _load
products

A date range

Dates work the same way. Here, products added since the first of June, twenty twenty five. Now minus one year, and other date maths, work too. Run it.

Dev Tools Consoletext
GET products/_search?filter_path=hits.total.value,hits.hits._source.added
{
  "query": {
    "range": { "added": { "gte": "2025-06-01" } }
  },
  "size": 3
}
Output
{
  "hits": {
    "total": {"value": 8},
    "hits": [
      {"_source": {"added": "2025-08-07"}},
      {"_source": {"added": "2025-11-11"}},
      {"_source": {"added": "2025-09-16"}}
    ]
  }
}
Also uses _load
products

Summary

Range uses g t, g t e, l t and l t e, for numbers and dates. Next, a few more query types.

Key takeaways
  • gte / lte
  • Numbers
  • Dates
Next up: exists, prefix and wildcard — handy extras