AWS IoT 搜索动态事物组
AWS IoT search for dynamic Thing Group
我想查找动态事物组列表。当我转到 AWS IoT Core 中的事物组之一时,我可以看到字段类型。如何搜索和查找 Type
为 Dynamic
的事物组列表?
例如
当我访问 IoT Core 中存在的事物组之一时。
You do not have a description for the thing group yet.
Created
Jul 26, 2019 11:21:44 AM -0700
Type
Static
0 Attributes
我尝试了几个变体,但都没有用。
Type: Dynamic
attributes.Type: Dynamic
Type == Dynamic
提前感谢您的任何建议。
看起来不太直白。感谢我的同事,我创建了一个脚本来获取该列表。
import boto3
client = boto3.client('iot')
list_thing_groups = client.list_thing_groups()
while True:
for thing_group in list_thing_groups['thingGroups']:
name = thing_group['groupName']
response = client.describe_thing_group(
thingGroupName=name
)
query = response.get('queryString')
if query:
print(name)
if list_thing_groups.get('nextToken'):
list_thing_groups = client.list_thing_groups(nextToken=list_thing_groups.get('nextToken'))
else:
break
想法是queryString
动态事物组不会为空。
- 配置一个Thing Group index on Fleet Indexing.
- 对于创建的每个动态事物组,添加一个属性以将其区分为动态事物组,即
attribute.dynamic: true
- 使用查询
attributes.dynamic: true
在索引上调用 SearchIndex,这将 return 所有动态事物组。
我想查找动态事物组列表。当我转到 AWS IoT Core 中的事物组之一时,我可以看到字段类型。如何搜索和查找 Type
为 Dynamic
的事物组列表?
例如
当我访问 IoT Core 中存在的事物组之一时。
You do not have a description for the thing group yet.
Created
Jul 26, 2019 11:21:44 AM -0700
Type
Static
0 Attributes
我尝试了几个变体,但都没有用。
Type: Dynamic
attributes.Type: Dynamic
Type == Dynamic
提前感谢您的任何建议。
看起来不太直白。感谢我的同事,我创建了一个脚本来获取该列表。
import boto3
client = boto3.client('iot')
list_thing_groups = client.list_thing_groups()
while True:
for thing_group in list_thing_groups['thingGroups']:
name = thing_group['groupName']
response = client.describe_thing_group(
thingGroupName=name
)
query = response.get('queryString')
if query:
print(name)
if list_thing_groups.get('nextToken'):
list_thing_groups = client.list_thing_groups(nextToken=list_thing_groups.get('nextToken'))
else:
break
想法是queryString
动态事物组不会为空。
- 配置一个Thing Group index on Fleet Indexing.
- 对于创建的每个动态事物组,添加一个属性以将其区分为动态事物组,即
attribute.dynamic: true
- 使用查询
attributes.dynamic: true
在索引上调用 SearchIndex,这将 return 所有动态事物组。