RangeFilter document (Data API 18.3)
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). It is configurable whether the
lower and/or the upper bound is inclusive or exclusive.
A range filter is useful for general restrictions that can be shared between searches (like a static date range) as
the filter result is cached in memory. Range filters are not appropriate if the range is expected to be different for
every single query (like if the user controls the date range down to the hour via some 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 configured lower bound of the filter range. The lower bound is optional. If not given, the range is open ended with respect to the lower bound. | |
from_inclusive
|
Boolean | A flag indicating whether the lower bound of the range is inclusive (or exclusive). The default is true (which means that the given lower bound is inclusive). | |
to
|
Object | The configured upper bound of the filter range. The upper bound is optional. If not given, the range is open ended with respect to the upper bound. | |
to_inclusive
|
Boolean | A flag indicating whether the upper bound of the range is inclusive (or exclusive). The default is true (which means that the given upper bound is inclusive). |
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.