BoolFilter document (Data API 20.4)

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.
OCAPI obsolete versions 13.x and 14.x will be end of life in 2020 and versions 15.x and 16.x in 2021. For dates and more information, see the OCAPI versioning and deprecation policy and this Knowledge Article.
X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used. By continuing to use this site you are giving us your consent to do this. Privacy Policy.