Key matching
You can use the exists
operator to match incoming messages with or
without specified properties in the filter policy. exists
matching only
works on leaf nodes. It does not work on intermediate nodes.
-
Use
"exists": true
to match incoming messages that include the specified property. The key must have a non-null and non-empty value.For example, the following policy property uses the
exists
operator with a value oftrue
:"store": [{"exists": true}]
It matches any list of message attributes that contains the
store
attribute key, such as the following:"store": {"Type": "String", "Value": "fans"} "customer_interests": {"Type": "String.Array", "Value": "[\"baseball\", \"basketball\"]"}
It also matches either of the following message body:
{ "store": "fans" "customer_interests": ["baseball", "basketball"] }
However, it doesn't match any list of message attributes without the
store
attribute key, such as the following:"customer_interests": {"Type": "String.Array", "Value": "[\"baseball\", \"basketball\"]"}
Nor does it match the following message body:
{ "customer_interests": ["baseball", "basketball"] }
-
Use
"exists": false
to match incoming messages that don't include the specified property.Note
"exists": false
only matches if at least one attribute is present. An empty set of attributes results in the filter not matching.For example, the following policy property uses the
exists
operator with a value offalse
:"store": [{"exists": false}]
It doesn't match any list of message attributes that contains the
store
attribute key, such as the following:"store": {"Type": "String", "Value": "fans"} "customer_interests": {"Type": "String.Array", "Value": "[\"baseball\", \"basketball\"]"}
It also doesn’t match the following message body:
{ "store": "fans" "customer_interests": ["baseball", "basketball"] }
However, it matches any list of message attributes without the
store
attribute key, such as the following:"customer_interests": {"Type": "String.Array", "Value": "[\"baseball\", \"basketball\"]"}
It also matches the following message body:
{ "customer_interests": ["baseball", "basketball"] }