首页 > 解决方案 > 在“或”条件下过滤 AWS SNS 消息

问题描述

SNS 消息过滤页面上有一个 AND/OR Logic 的示例,如下所示

AND 逻辑:通过使用多个属性名称(键)应用 AND 逻辑。例如,政策:

{
    "customer_interests": ["rugby"],
    "price_usd": [{"numeric":[">", 100]}]
}

OR 逻辑:通过为属性名称分配多个值来应用 OR 逻辑。例如,策略属性:

"customer_interests": ["rugby", "football", "baseball"]

但是,我们如何为多个属性名称(键)应用“或”逻辑

因此,例如,如果我想更改第一个示例,政策将是什么

(customer_interests="rugby" AND price_usd > 100)

(customer_interests="rugby" OR price_usd > 100)

标签: amazon-web-servicesfilteramazon-sns

解决方案


您必须为同一端点创建 2 个单独的订阅并附加不同的过滤器:

第一次订阅:

{
    "customer_interests": ["rugby"]
}

第二次订阅:

{   
   "price_usd": [{"numeric":[">", 100]}]
}

我没有找到任何在单个过滤器中使用 OR 的方法,但是通过创建对同一端点的多个订阅肯定有效(在我的帐户上使用了 mysqlf)


推荐阅读