쿠키 기본 설정 선택

당사는 사이트와 서비스를 제공하는 데 필요한 필수 쿠키 및 유사한 도구를 사용합니다. 고객이 사이트를 어떻게 사용하는지 파악하고 개선할 수 있도록 성능 쿠키를 사용해 익명의 통계를 수집합니다. 필수 쿠키는 비활성화할 수 없지만 '사용자 지정' 또는 ‘거부’를 클릭하여 성능 쿠키를 거부할 수 있습니다.

사용자가 동의하는 경우 AWS와 승인된 제3자도 쿠키를 사용하여 유용한 사이트 기능을 제공하고, 사용자의 기본 설정을 기억하고, 관련 광고를 비롯한 관련 콘텐츠를 표시합니다. 필수가 아닌 모든 쿠키를 수락하거나 거부하려면 ‘수락’ 또는 ‘거부’를 클릭하세요. 더 자세한 내용을 선택하려면 ‘사용자 정의’를 클릭하세요.

시작하기(AWS SDK for Python (Boto3)) - Amazon Kendra

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

시작하기(AWS SDK for Python (Boto3))

다음 프로그램은 Python 프로그램에서 Amazon Kendra 를 사용하는 예제입니다. 프로그램이 실행하는 작업은 다음과 같습니다.

  1. CreateIndex 작업을 사용하여 새 인덱스를 만듭니다.

  2. 인덱스 생성이 완료될 때까지 기다립니다. DescribeIndex 작업을 사용하여 인덱스 상태를 모니터링합니다.

  3. 인덱스가 활성화되면 CreateDataSource 작업을 사용하여 데이터 소스를 만듭니다.

  4. 데이터 소스 생성이 완료될 때까지 기다립니다. DescribeDataSource 작업을 사용하여 데이터 소스 상태를 모니터링합니다.

  5. 데이터 소스가 활성 상태이면 StartDataSourceSyncJob 작업을 사용하여 인덱스를 데이터 소스의 내용과 동기화합니다.

import boto3 from botocore.exceptions import ClientError import pprint import time kendra = boto3.client("kendra") print("Create an index.") # Provide a name for the index index_name = "python-getting-started-index" # Provide an optional decription for the index description = "Getting started index" # Provide the IAM role ARN required for indexes index_role_arn = "arn:aws:iam::${accountId}:role/KendraRoleForGettingStartedIndex" try: index_response = kendra.create_index( Description = description, Name = index_name, RoleArn = index_role_arn ) pprint.pprint(index_response) index_id = index_response["Id"] print("Wait for Amazon Kendra to create the index.") while True: # Get the details of the index, such as the status index_description = kendra.describe_index( Id = index_id ) # When status is not CREATING quit. status = index_description["Status"] print(" Creating index. Status: "+status) time.sleep(60) if status != "CREATING": break print("Create an S3 data source.") # Provide a name for the data source data_source_name = "python-getting-started-data-source" # Provide an optional description for the data source data_source_description = "Getting started data source." # Provide the IAM role ARN required for data sources data_source_role_arn = "arn:aws:iam::${accountId}:role/KendraRoleForGettingStartedDataSource" # Provide the data source connection information S3_bucket_name = "S3-bucket-name" data_source_type = "S3" # Configure the data source configuration = {"S3Configuration": { "BucketName": S3_bucket_name } } """ If you connect to your data source using a template schema, configure the template schema configuration = {"TemplateConfiguration": { "Template": {JSON schema} } } """ data_source_response = kendra.create_data_source( Name = data_source_name, Description = data_source_name, RoleArn = data_source_role_arn, Type = data_source_type, Configuration = configuration, IndexId = index_id ) pprint.pprint(data_source_response) data_source_id = data_source_response["Id"] print("Wait for Amazon Kendra to create the data source.") while True: # Get the details of the data source, such as the status data_source_description = kendra.describe_data_source( Id = data_source_id, IndexId = index_id ) # If status is not CREATING, then quit status = data_source_description["Status"] print(" Creating data source. Status: "+status) time.sleep(60) if status != "CREATING": break print("Synchronize the data source.") sync_response = kendra.start_data_source_sync_job( Id = data_source_id, IndexId = index_id ) pprint.pprint(sync_response) print("Wait for the data source to sync with the index.") while True: jobs = kendra.list_data_source_sync_jobs( Id = data_source_id, IndexId = index_id ) # For this example, there should be one job status = jobs["History"][0]["Status"] print(" Syncing data source. Status: "+status) if status != "SYNCING": break time.sleep(60) except ClientError as e: print("%s" % e) print("Program ends.")
프라이버시사이트 이용 약관쿠키 기본 설정
© 2025, Amazon Web Services, Inc. 또는 계열사. All rights reserved.