索引鍵比對 - Amazon Simple Notification Service

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

索引鍵比對

您可以使用 exists 運算子在篩選原則中配對具有或不具有指定屬性的傳入訊息。exists 比對僅適用於葉節點。它不適用於中繼節點。

  • 使用 "exists": true 配對包含指定屬性的傳入訊息。該鍵必須具有非空值和非空值。

    例如,下列政策屬性會使用 exists 運算子及為 true 的值:

    "store": [{"exists": true}]

    它符合具有 store 屬性索引鍵的任何訊息屬性,如下所示:

    "store": {"Type": "String", "Value": "fans"} "customer_interests": {"Type": "String.Array", "Value": "[\"baseball\", \"basketball\"]"}

    它也符合以下任一訊息內文:

    { "store": "fans" "customer_interests": ["baseball", "basketball"] }

    不過,不符合不具有 store 屬性索引鍵的任何訊息屬性,如下所示:

    "customer_interests": {"Type": "String.Array", "Value": "[\"baseball\", \"basketball\"]"}

    它也不符合以下訊息內文:

    { "customer_interests": ["baseball", "basketball"] }
  • 使用 "exists": false 配對包含指定屬性的傳入訊息。

    注意

    "exists": false 只有在至少有一個屬性存在時才相符。一組空白的屬性會導致篩選條件不相符。

    例如,下列政策屬性會使用 exists 運算子及為 false 的值:

    "store": [{"exists": false}]

    符合具有 store 屬性索引鍵的任何訊息,如下所示:

    "store": {"Type": "String", "Value": "fans"} "customer_interests": {"Type": "String.Array", "Value": "[\"baseball\", \"basketball\"]"}

    它也不符合以下訊息內文:

    { "store": "fans" "customer_interests": ["baseball", "basketball"] }

    不過,它符合不具有 store 屬性索引鍵的任何訊息屬性,如下所示:

    "customer_interests": {"Type": "String.Array", "Value": "[\"baseball\", \"basketball\"]"}

    它也符合以下訊息內文:

    { "customer_interests": ["baseball", "basketball"] }