將 UpdateIndexingConfiguration 與 AWS SDK 或 CLI 搭配使用 - AWS SDK 程式碼範例

AWS文件開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例。

UpdateIndexingConfiguration 與 AWS SDK 或 CLI 搭配使用

下列程式碼範例示範如何使用 UpdateIndexingConfiguration

C++
SDK for C++
注意

GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

//! Update the indexing configuration. /*! \param thingIndexingConfiguration: A ThingIndexingConfiguration object which is ignored if not set. \param thingGroupIndexingConfiguration: A ThingGroupIndexingConfiguration object which is ignored if not set. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::IoT::updateIndexingConfiguration( const Aws::IoT::Model::ThingIndexingConfiguration &thingIndexingConfiguration, const Aws::IoT::Model::ThingGroupIndexingConfiguration &thingGroupIndexingConfiguration, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::IoT::IoTClient iotClient(clientConfiguration); Aws::IoT::Model::UpdateIndexingConfigurationRequest request; if (thingIndexingConfiguration.ThingIndexingModeHasBeenSet()) { request.SetThingIndexingConfiguration(thingIndexingConfiguration); } if (thingGroupIndexingConfiguration.ThingGroupIndexingModeHasBeenSet()) { request.SetThingGroupIndexingConfiguration(thingGroupIndexingConfiguration); } Aws::IoT::Model::UpdateIndexingConfigurationOutcome outcome = iotClient.UpdateIndexingConfiguration( request); if (outcome.IsSuccess()) { std::cout << "UpdateIndexingConfiguration succeeded." << std::endl; } else { std::cerr << "UpdateIndexingConfiguration failed." << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
CLI
AWS CLI

啟用物件索引

下列 update-indexing-configuration 範例啟用物件索引,並使用 AWS_Things 索引來支援搜尋登錄檔資料、影子資料和物件連線狀態。

aws iot update-indexing-configuration --thing-indexing-configuration thingIndexingMode=REGISTRY_AND_SHADOW,thingConnectivityIndexingMode=STATUS

此命令不會產生輸出。

如需詳細資訊,請參閱《AWS IoT 開發人員指南》中的管理物件索引