

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

# 사전 업데이트
<a name="index-synonyms-update"></a>

사전이 생성된 이후 구성을 변경할 수 있습니다. 사전 이름 및 IAM 정보와 같은 세부 정보를 변경할 수 있습니다. 또한 사전 파일 Amazon S3 경로의 위치를 변경할 수 있습니다. 사전 파일의 경로를 변경하면 Amazon Kendra 가 기존 사전을 업데이트된 경로에 지정된 사전으로 대체합니다.

업데이트된 사전 파일의 효과를 확인하는 데 최대 30분이 소요될 수 있습니다.

**참고**  
사전 파일에 검증 또는 구문 오류가 있는 경우 이전에 업로드한 사전 파일이 보존됩니다.

다음 절차는 사전 세부 정보를 수정하는 방법을 보여줍니다.

------
#### [ Console ]

**사전 세부 정보를 수정하는 방법**

1. 왼쪽 탐색 창의 수정할 인덱스에서 **동의어**를 선택합니다.

1. **동의어** 페이지에서 수정하려는 사전을 선택한 다음 **편집**을 선택합니다.

1. **사전 업데이트** 페이지에서 사전 세부 정보를 업데이트합니다.

1. (선택 사항) **사전 파일 경로 변경을** 선택한 다음 새 사전 파일의 Amazon S3 경로를 지정합니다. 기존 사전 파일은 지정한 파일로 대체됩니다. 경로를 변경하지 않으면가 기존 경로에서 사전을 Amazon Kendra 다시 로드합니다.

   **현재 사전 파일 유지를** 선택하면가 사전 파일을 다시 로드하지 Amazon Kendra 않습니다.

1. **저장**을 선택하여 구성을 저장합니다.

기존 사전 경로에서 사전을 다시 로드할 수도 있습니다.

**기존 경로에서 사전을 다시 로드하려면**

1. 왼쪽 탐색 창의 수정할 인덱스에서 **동의어**를 선택합니다.

1. **동의어** 페이지에서 다시 로드하려는 사전을 선택한 다음 **새로 고침**을 선택합니다.

1. **사전 파일 다시 로드** 페이지에서 사전 파일을 새로 고칠지 확인합니다.

------
#### [ CLI ]

사전을 업데이트하려면 다음을 호출하세요. `update-thesaurus` 

```
aws kendra update-thesaurus \
--index-id {{index-id}} \
--name "{{thesaurus-name}}" \
--description "{{thesaurus-description}}" \
--source-s3-path "Bucket={{bucket-name}},Key={{thesaurus/synonyms.txt}}" \
--role-arn {{role-arn}}
```

------
#### [ Python ]

```
import boto3
from botocore.exceptions import ClientError
import pprint
import time

kendra = boto3.client("kendra")

print("Update a thesaurus")

thesaurus_name = "{{thesaurus-name}}"
thesaurus_description = "{{thesaurus-description}}"
thesaurus_role_arn = "{{role-arn}}"

thesaurus_id = "{{thesaurus-id}}"
index_id = "{{index-id}}"

s3_bucket_name = "{{bucket-name}}"
s3_key = "{{thesaurus-file}}"
source_s3_path= {
    'Bucket': s3_bucket_name,
    'Key': s3_key
}

try:
    kendra.update_thesaurus(
        Id = thesaurus_id,
        IndexId = index_id,
        Description = thesaurus_description,
        Name = thesaurus_name,
        RoleArn = thesaurus_role_arn,
        SourceS3Path = source_s3_path
    )
    
    print("Wait for Kendra to update the thesaurus.")

    while True:
        # Get thesaurus description
        thesaurus_description = kendra.describe_thesaurus(
            Id = thesaurus_id,
            IndexId = index_id
        )
        # If status is not UPDATING quit
        status = thesaurus_description["Status"]
        print("Updating thesaurus. Status: " + status)
        if status != "UPDATING":
            break
        time.sleep(60)

except ClientError as e:
        print("%s" % e)

print("Program ends.")
```

------
#### [ Java ]

```
package com.amazonaws.kendra;

import software.amazon.awssdk.services.kendra.KendraClient;
import software.amazon.awssdk.services.kendra.model.UpdateThesaurusRequest;
import software.amazon.awssdk.services.kendra.model.DescribeThesaurusRequest;
import software.amazon.awssdk.services.kendra.model.DescribeThesaurusResponse;
import software.amazon.awssdk.services.kendra.model.S3Path;
import software.amazon.awssdk.services.kendra.model.ThesaurusStatus;

public class UpdateThesaurusExample {

  public static void main(String[] args) throws InterruptedException {

    KendraClient kendra = KendraClient.builder().build();

    String thesaurusName = "{{thesaurus-name}}";
    String thesaurusDescription = "{{thesaurus-description}}";
    String thesaurusRoleArn = "{{role-arn}}";

    String s3BucketName = "{{bucket-name}}";
    String s3Key = "{{thesaurus-file}}";

    String thesaurusId = "{{thesaurus-id}}";
    String indexId = "{{index-id}}";

    UpdateThesaurusRequest updateThesaurusRequest = UpdateThesaurusRequest
        .builder()
        .id(thesaurusId)
        .indexId(indexId)
        .name(thesaurusName)
        .description(thesaurusDescription)
        .roleArn(thesaurusRoleArn)
        .sourceS3Path(S3Path.builder()
            .bucket(s3BucketName)
            .key(s3Key)
            .build())
        .build();
    kendra.updateThesaurus(updateThesaurusRequest);

    System.out.println(String.format("Waiting until the thesaurus with ID %s is updated.", thesaurusId));

    // a new source s3 path requires re-consumption by Kendra 
    // and so can take as long as a Create Thesaurus operation
    while (true) {
      DescribeThesaurusRequest describeThesaurusRequest = DescribeThesaurusRequest.builder()
          .id(thesaurusId)
          .indexId(indexId)
          .build();
      DescribeThesaurusResponse describeThesaurusResponse = kendra.describeThesaurus(describeThesaurusRequest);
      ThesaurusStatus status = describeThesaurusResponse.status();
      if (status != ThesaurusStatus.UPDATING) {
        break;
      }

      TimeUnit.SECONDS.sleep(60);
    }

    System.out.println("Thesaurus update is complete.");
  }
}
```

------