View a markdown version of this page

開始使用 (AWS CLI) - Amazon Kendra

Amazon Kendra 從 2026 年 7 月 30 日開始, 將不再開放給新客戶。如果您想要使用 服務,請在 7 月 30 日之前註冊。對於類似 的功能 Amazon Kendra,探索 Amazon Bedrock 知識庫。進一步了解。

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

開始使用 (AWS CLI)

下列程序說明如何使用 建立 Amazon Kendra 索引 AWS CLI。程序會建立資料來源、索引,並在索引上執行查詢。

建立 Amazon Kendra 索引 (CLI)
  1. 執行 先決條件

  2. 輸入下列命令來建立索引。

    aws kendra create-index \ --name cli-getting-started-index \ --description "Index for CLI getting started guide." \ --role-arn arn:aws:iam::account id:role/KendraRoleForGettingStartedIndex
  3. 等待 Amazon Kendra 建立索引。使用以下命令檢查進度。當狀態欄位為 時ACTIVE,請繼續下一個步驟。

    aws kendra describe-index \ --id index id
  4. 在命令提示字元中,輸入下列命令來建立資料來源。

    aws kendra create-data-source \ --index-id index id \ --name data source name \ --role-arn arn:aws:iam::account id:role/KendraRoleForGettingStartedDataSource \ --type S3 \ --configuration '{"S3Configuration":{"BucketName":"S3 bucket name"}}'

    如果您使用範本結構描述連線至資料來源,請設定範本結構描述。

    aws kendra create-data-source \ --index-id index id \ --name data source name \ --role-arn arn:aws:iam::account id:role/KendraRoleForGettingStartedDataSource \ --type TEMPLATE \ --configuration '{"TemplateConfiguration":{"Template":{JSON schema}}}'
  5. 建立資料來源需要 Amazon Kendra 一些時間。輸入下列命令來檢查進度。當狀態為 時ACTIVE,請繼續下一個步驟。

    aws kendra describe-data-source \ --id data source ID \ --index-id index ID
  6. 輸入下列命令來同步資料來源。

    aws kendra start-data-source-sync-job \ --id data source ID \ --index-id index ID
  7. Amazon Kendra 會為您的資料來源編製索引。所需的時間量取決於文件數量。您可以使用下列命令檢查同步任務的狀態。當狀態為 時ACTIVE,請繼續下一個步驟。

    aws kendra describe-data-source \ --id data source ID \ --index-id index ID
  8. 輸入下列命令進行查詢。

    aws kendra query \ --index-id index ID \ --query-text "search term"

    搜尋結果會以 JSON 格式顯示。