Filter operators
Operators connect two items in the filter expression that need to be evaluated against each other, for example, [left item] [operator] [right item]. Operators can be placed both between two items in the expression and follow them. The type of evaluation depends on the type of operator:
- Basic operators
- String operators
- Range and set operators
- Collection-specific operators
- Map-specific operator
In the following examples the [a] and [b] elements are filter identifiers (also called operands). For more information, see Filter-identifiers.
Basic operators
Basic operators are also called arithmetic. See the description for basic operators in the following list:
- [a] IS [b] — Tests whether [a] is equal to [b]
- [a] = [b] — Tests whether [a] is equal to [b]
- [a] != [b] — Tests whether [a] is different from [b]
- [a] <> [b] — Tests whether [a] is different from [b]
- [a] > [b] — Tests whether [a] is greater than [b]
- [a] >= [b] — Tests whether [a] is greater than or equal to [b]
- [a] < [b] — Tests whether [a] is less than the right
- [a] <= [b] — Tests whether [a] is less than or equal to [b]
String operators
See the description for string operators in the following list:
- [a] startswith "xyz" — Tests whether the string on the left starts with the string on the right ("xyz")
- [a] endswith "xyz" — Tests whether the string on the left ends with the string on the right
- [a] contains "xyz" — Tests whether the string on the left contains the string on the right
- [a] regex [pattern] — Tests whether [a] is matched by the regular expression [pattern]
- [a] [operator] [b] ignorecase — Ensures that the [operator] is case insensitive when comparing [a] with [b]. By default, all string operators are case sensitive.
Range and set operators
See the description for range and set operators in the following list:
- [a] between [lower] [upper] — Tests whether [a] is within the range defined by [lower] and [upper]. The boundary comparisons are inclusive — that is, [lower] <= [a] <= [upper].
- [a] in ([value1],[value2],...) — Tests whether [a] is a member of a set of values. The value set must be enclosed parentheses and the values in the set must be separated by commas.
Collection-specific operators
See examples and description for collection-specific operators in the following list:
- [a] [operator] [b] all — Iterates over the elements of [a], which must be a collection identifier, using each element in that collection as the left operand in a comparison with [b] — that is, [element] [operator] [b]. The comparison must be true for every element. If a single element fails the comparison, the overall evaluation is false.
- [a] [operator] [a] any — Iterates over the elements of [a], which must be a collection identifier, using each element in that collection as the left operand in a comparison with [b] — that is, [element] [operator] [b]. The comparison must be true for at least one element. Otherwise the overall evaluation is false.
- [a] [operator] [b] occurs [integer][sign] — Iterates over the elements of [a], which must be a collection identifier, using each element in that collection as the left operand in a comparison with [b] — that is, [element] [operator] [b]. The positive comparisons are counted and the resulting total is compared against the specified [integer] and optional [+|-]:
- + : Total should be greater than or equal to the integer
- - : Total should be less than or equal to the integer
- None: Total must be equal to the integer
Map-specific operator
[a] haskey [b] — Tests whether [a], which must be a map identifier, contains [b] as a key.
Grouping terms in an expression
To group terms in an expression, use logical operators AND, OR, and parentheses as in the following expression:
The AND operator is interchangeable with the && operator. The OR operator is interchangeable with the || operator. The NOT operator is interchangeable with the ! operator.
Negation
Predicate and group negation is represented by NOT, as in the following expressions:
Related topics