RangeFilter document (Data API 23.2)
Document representing a range filter.
A range filter allows you to restrict a search result to hits that have values for a given attribute that fall into a
given value range. The range filter supports several value types, and relies on the natural sorting of the value type
for range interpretation. Value ranges can be open-ended (at one end only). You can configure whether the
lower and upper bounds are inclusive or exclusive.
A range filter is useful for general restrictions that can be shared between searches (like a static date range) because
the filter result is cached in memory. Range filters are not appropriate if the range is expected to be different for
every query (for example, if the user controls the date range down to the hour via a UI control). Range filters
are inclusive by default.
Example: ( redemption_count BETWEEN (0,10] )
query: { filtered_query: { query: { match_all_query: {} }, filter: { range_filter: { field: "redemption_count", from: 0, to: 10, from_inclusive: false } } } }
Property | Type | Constraints | Description |
---|---|---|---|
field |
String | mandatory=true, nullable=false | The search field. |
from |
Object | The lower bound of the filter range. If not specified, the range is open-ended with respect to the lower bound. You can't leave both the lower and upper bounds open-ended. | |
from_inclusive |
Boolean | Indicates whether the lower bound of the range is inclusive. If not specified, the default is true. Set to false to make the lower bound exclusive. | |
to |
Object | The upper bound of the filter range. If not specified, the range is open-ended with respect to the upper bound. You can't leave both the upper and lower bounds open-ended. | |
to_inclusive |
Boolean | Indicates whether the upper bound of the range is inclusive. If not specified, the default is true. Set to false to made the upper bound exclusive. |
X
OCAPI versions 15.x and 16.x will be retired on March 31, 2021. For dates and more information, see the OCAPI versioning and deprecation policy and this Knowledge Article.