事物查询示例 - Amazon IoT Core
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

事物查询示例

使用查询语法在查询字符串中指定查询。查询将传递给SearchIndexAPI。下表列出了一些查询字符串示例。

查询字符串 结果
abc

在任何注册表、影子(经典未命名影子和命名影子)或 Device Defender 违规字段中查询“abc”。

thingName:myThingName

查询名为 “myThingName” 的事物。

thingName:my*

查询名称以“my”开头的事物。

thingName:ab?

查询名称为“ab”加另外一个字符的事物(例如:“aba”、“abb”、“abc”等)。

thingTypeName:aa

查询与类型 aa 关联的事物。

thingGroupNames:a 查询父事物组名称为“a”的事物。
thingGroupNames:a* 查询父事物组名称与模式“a*”匹配的事物。
attributes.myAttribute:75

查询属性名为“myAttribute”且属性值为 75 的事物。

attributes.myAttribute:[75 TO 80]

查询属性名为“myAttribute”,且属性值在数字范围(75-80,含 75 和 80)之内的事物。

attributes.myAttribute:{75 TO 80]

查询属性名为“myAttribute”,且属性值在数字范围(大于 75 且小于等于 80)之内的事物。

attributes.serialNumber:["abcd" TO "abcf"]

查询属性名为“serialNumber”,且属性值在字母数字字符串范围之内的事物。此查询将返回属性名为“serialNumber”,且其值为“abcd”、“abce”或“abcf”的事物。

attributes.myAttribute:i*t

查询属性名为“myAttribute”,且属性值为以“i”开头、以“t”结尾、中间有任意数量字符的事物。

attributes.attr1:abc AND attributes.attr2<5 NOT attributes.attr3>10

使用布尔表达式组合术语来查询事物。此查询将返回具有下列特征的事物:属性名为“attr1”且值为“abc”;属性名为“attr2”且值小于 5;以及属性名为“attr3”且值不大于 10。

shadow.hasDelta:true

查询具有增量元素的未命名影子的事物。

NOT attributes.model:legacy

查询属性名为“model”且不是“legacy”的事物。

shadow.reported.stats.battery:{70 TO 100} (v2 OR v3) NOT attributes.model:legacy

查询具有以下特征的事物:

  • 事物的影子 stats.battery 属性具有介于 70 到 100 之间的值。

  • 文本“v2”或“v3”出现在事物的名称、类型名称或属性值中。

  • 事物的 model 属性未设置为“legacy”。

shadow.reported.myvalues:2

查询具有以下特征的事物:影子的“reported”部分中的 myvalues 数组包含值 2。

shadow.reported.location:* NOT shadow.desired.stats.battery:*

查询具有以下特征的事物:

  • 影子的 location 部分中存在 reported 属性。

  • 影子的 desired 部分中不存在 stats.battery 属性。

shadow.name.<shadowName>.hasDelta:true

查询具有给定名称和增量元素影子的东西。

shadow.name.<shadowName>.desired.filament:*

查询具有给定名称和所需灯丝特性的阴影的对象。

shadow.name.<shadowName>.reported.location:*

查询具有具有给定命名影子且 location 属性存在于命名影子的报告部分中的事物。

connectivity.connected:true

查询所有连接的设备。

connectivity.connected:false 查询所有断开连接的设备。
connectivity.connected:true AND connectivity.timestamp : [1557651600000 TO 1557867600000] 查询所有已连接且连接时间戳 >= 1557651600000 且 <= 1557867600000 的设备。时间戳以自纪元以来的毫秒数给出。
connectivity.connected:false AND connectivity.timestamp : [1557651600000 TO 1557867600000] 查询所有已断开连接且断开连接时间戳 >= 1557651600000 且 <= 1557867600000 的设备。时间戳以自纪元以来的毫秒数给出。
connectivity.connected:true AND connectivity.timestamp > 1557651600000 查询所有已连接且连接时间戳 > 1557651600000 的设备。时间戳以自纪元以来的毫秒数给出。
connectivity.connected:* 查询具有连接信息的所有设备。
connectivity.disconnectReason:* 查询具有连接断开原因的所有设备。
connectivity.disconnectReason:CLIENT_INITIATED_DISCONNECT 查询由于 CLIENT_INITATE_DISKINATE_DISKINTION 而断开的所有设备
deviceDefender.violationCount:[0 TO 100] 查询设备计数值在数字范围(0-100)内的 Device Defender 违规事物。
deviceDefender.<device-SecurityProfile>.disconnectBehavior.inViolation:true 查询违反安全配置文件 device-SecurityProfile 中定义的行为 disconnectBehavior 的事物。请注意,inViolation:false 不是有效的查询。
deviceDefender.<device-SecurityProfile>.disconnectBehavior.lastViolationValue.number>2 查询与安全配置文件设备中disconnectBehavior定义的行为相违规的事情—— SecurityProfile 上次违规事件值大于 2。
deviceDefender.<device-SecurityProfile>.disconnectBehavior.lastViolationTime>1634227200000

查询SecurityProfile 与安全配置文件设备中disconnectBehavior定义的行为相冲突的事情——最后一次违规事件发生在指定的纪元时间之后。

shadow.name.gps-tracker.reported.coordinates:geo_distance,47.6204,-122.3491,15.5km 查询距离坐标 47.6204、-122.3491 的径向距离在 15.5 千米以内的事物。此查询字符串适用于您的位置数据存储在命名影子中的情况。
shadow.reported.coordinates:geo_distance,47.6204,-122.3491,15.5km 查询距离坐标 47.6204、-122.3491 的径向距离在 15.5 千米以内的事物。此查询字符串适用于您的位置数据存储在经典阴影中的情况。