Range Queries
Filter by numeric ranges and date comparisons using gt, gte, lt, lte operators. Use setGroup with "and" type to combine range conditions. Perfect for price filters, date ranges, stock thresholds, and rating cutoffs.
Syntax
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
groupKey | string | Yes | Unique identifier for the group, allows updating/removing later |
type | 'and' | Yes | Use "and" to require all conditions match (range behavior) |
conditions | Condition[] | Yes | Array of conditions with attribute, operator (gt/gte/lt/lte), and value |
Return Type
Returns void. Use setGroup to combine gt/gte with lt/lte for bounded ranges.
Usage Notes
- Use setGroup with type "and" to combine gte + lte for ranges
- groupKey allows you to update or remove the range filter later
- Works with numbers, dates, and string comparisons
- For dates, use Date objects or ISO strings
- Use gt (exclusive) when you want to exclude the boundary
- Use gte (inclusive) when you want to include the boundary
Related Methods
catalog.query.setGroup()- Create grouped conditions with AND/OR logiccatalog.fn.aggregate()- Get min/max values for range boundsQuery Filter- Exact match filteringQuery Logic- Complex AND/OR combinations
Examples
Minimum Price Filter
Find products priced above a threshold using greater-than.
Maximum Price Filter
Find products under a price limit using less-than-or-equal.
Price Range (Inclusive)
Find products between $50 and $200 (inclusive on both ends).
Price Range (Exclusive)
Find products between $50 and $200 (exclusive on both ends).
Low Stock Alert
Find products with critically low inventory.
Date After (Recent Items)
Find orders placed on or after a specific date.
Date Range (Last 30 Days)
Find items created within the last 30 days.
Rating Threshold
Find products with 4+ stars rating.
Combine Range with Other Filters
Find electronics between $100-$500 that are in stock.