BoolFilter document (Data API 23.2)
Document representing a boolean filter.
A boolean filter allows you to combine other filters into (possibly recursive) logical expression trees. A boolean filter
is configured with a boolean operator (AND, OR, NOT) and a list of filters the operator relates to. If multiple
filters are given to a boolean NOT operator, this is interpreted as a NOT upon a boolean AND of the given filters.
Example: (id="myId" AND coupon_id="couponOne")
query: { filtered_query: { query: { match_all_query: {} }, filter: { bool_filter: { operator: "and", filters: [ { term_filter: { field: "id", operator: "is", values: ["myId"] } }, { term_filter: { field: "coupon_id", operator: "is", values: ["couponOne"] } } ] } } } }Example: (id="holidaySale" OR redemption_count BETWEEN(1, 20)
query: { filtered_query: { query: { match_all_query: {} }, filter: { bool_filter: { operator: "or", filters: [ { term_filter: { field: "id", operator: "is", values: ["holidaySale"] } }, { range_filter: { field: "redemption_count", from: 1, to: 20 } } ] } } } }Example: NOT(enabled=false OR coupon_id="special")
query: { filtered_query: { query: { match_all_query: {} }, filter: { bool_filter: { operator: "not", filters: [ { term_filter: { field: "enabled", operator: "is", values: [false] } }, { term_filter: { field: "coupon_id", operator: "is", values: ["special"] } } ] } } } }
Property | Type | Constraints | Description |
---|---|---|---|
filters |
[Filter {BoolFilter, QueryFilter, Range2Filter, RangeFilter, TermFilter}] | A list of filters, which are logically combined by an operator. | |
operator |
Enum {and, or, not} | mandatory=true, nullable=false | The logical operator the filters are combined with. |
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.