BoolFilter Document (Data API 17.6)

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 AND 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 {TermFilter, RangeFilter, BoolFilter, QueryFilter, Range2Filter}]   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.