管理物件群組索引 - AWS IoT Core

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

管理物件群組索引

AWS_ThingGroups是包含所有物件群組和帳單群組的索引。您可以使用此索引,根據群組名稱、描述、屬性和所有父系群組名稱搜尋群組。

啟用物件群組索引

您可以使用thing-group-indexing-configuration設定 API 中的UpdateIndexing設定來建立索AWS_ThingGroups引並控制其設定。您可以使用GetIndexing設定 API 擷取目前的索引設定。

若要更新物件群組索引的組態,請執行 update-indexing-configuration CLI 命令:

aws iot update-indexing-configuration --thing-group-indexing-configuration thingGroupIndexingMode=ON

您也能以如下命令更新物件和物件群組索引的組態:

aws iot update-indexing-configuration --thing-indexing-configuration thingIndexingMode=REGISTRY --thing-group-indexing-configuration thingGroupIndexingMode=ON

以下是 thingGroupIndexingMode 的有效值。

OFF

不建立索引/刪除索引。

ON

建立或設定 AWS_ThingGroups 索引。

若要擷取目前物件和物件群組索引組態,請執行 get-indexing-configuration CLI 命令:

aws iot get-indexing-configuration

命令的回應如下所示:

{ "thingGroupIndexingConfiguration": { "thingGroupIndexingMode": "ON" } }

描述群組索引

若要擷取 describe-index 索引的目前狀態,請使用 AWS_ThingGroups CLI 命令:

aws iot describe-index --index-name "AWS_ThingGroups"

命令的回應如下所示:

{ "indexStatus": "ACTIVE", "indexName": "AWS_ThingGroups", "schema": "THING_GROUPS" }

AWS IoT 第一次建立索引時建立索引。若 indexStatusBUILDING,您無法在該索引內進行查詢。

查詢物件群組索引

若要查詢索引中的資料,請使用 search-index CLI 命令:

aws iot search-index --index-name "AWS_ThingGroups" --query-string "thingGroupName:mythinggroup*"

授權

您可以在 AWS IoT 原則動作中將物群組索引指定為資源 ARN,如下所示。

動作 資源

iot:SearchIndex

索引 ARN (例如,arn:aws:iot:your-aws-region:index/AWS_ThingGroups)。

iot:DescribeIndex

索引 ARN (例如,arn:aws:iot:your-aws-region:index/AWS_ThingGroups)。