evitaDB - Fast e-commerce database
logo
page-background

Range filtering

Range filtering is used to filter entities by the value of their attributes that are of a range type. It allows you to reduce the entity set to those entities whose range attribute includes the parameter value. If the parameter value is itself a range, only those entities with an overlapping range attribute will be matched.

In the context of the limitations described in this chapter, you might be interested in the general rules for handling data types and arrays described in the query language basics.

Attribute in range

argument:string!
the name of the entity attribute whose number range or datetime range value starts, ends, or encloses the value in the second argument
argument:comparable!

the value that must be within the attribute range to satisfy this constraint

The attributeInRange checks whether the value in the second argument is within the range of the attribute value. The value is within the range if it is equal to the start or end of the range or if it is between the start and end of the range.
Returns a list of products with a valid date/time range that includes the date "2023-12-05T12:00:00+01:00" - these are the products targeted for the holiday sale. In a real-world query, you would probably want to combine this constraint with attribute is NULL using the logical OR operator to also match products that have no date/time range attribute at all.

Attribute in range now

argument:string!
the name of the entity attribute whose number range or datetime range value starts, ends, or encloses the value in the second argument
The attributeInRangeNow checks whether the current date and time is within the range of the attribute value. Current date and time is within the range if it is equal to the start or end of the range or if it is between the start and end of the range.
Returns a list of products with a valid date/time range that includes the current date and time. The result of the example query cannot be listed here because it depends on the current date and time and may change from time to time.

Author: Ing. Jan Novotný

Date updated: 17.1.2023

Documentation Source