Field Operators
Range Operators
Range operators filter documents based on numeric or date field boundaries. You can use them to find values within a range, above a threshold, or below a limit.
| Operator | Description | Example |
|---|---|---|
$gt | Greater than (exclusive) | price > 100 |
$gte | Greater than or equal (inclusive) | price >= 100 |
$lt | Less than (exclusive) | price < 200 |
$lte | Less than or equal (inclusive) | price <= 200 |
You can combine multiple range operators on the same field to create bounded ranges.
For example, { $gte: 100, $lte: 200 } matches values from 100 to 200 inclusive.
For open-ended ranges, use a single operator.
For example, { $gt: 500 } matches all values greater than 500 with no upper limit.
Compatibility
| Field Type | Supported |
|---|---|
| TEXT | No |
| U64/I64/F64 | Yes |
| DATE | Yes |
| BOOL | No |
| KEYWORD | Yes |
| FACET | No |
Examples
// Price rangeawait products.query({ filter: { price: { $gte: 100, $lte: 200 }, },});// Open-ended range (no upper bound)await products.query({ filter: { price: { $gt: 500 }, },});// Date range (no lower bound)await users.query({ filter: { createdAt: { $lt: "2024-02-01T00:00:00Z" }, },});# Price rangeproducts.query(filter={"price": {"$gte": 100, "$lte": 200}})# Open-ended range (no upper bound)products.query(filter={"price": {"$gt": 500}})# Date range (no lower bound)users.query(filter={"createdAt": {"$lt": "2024-02-01T00:00:00Z"}})# Price rangeSEARCH.QUERY products '{"price": {"$gte": 100, "$lte": 200}}'# Open-ended range (no upper bound)SEARCH.QUERY products '{"price": {"$gt": 500}}'# Date range (no lower bound)SEARCH.QUERY users '{"createdAt": {"$lt": "2024-02-01T00:00:00Z"}}'