

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

# 인덱스 생성
<a name="create-index"></a>

콘솔을 사용하거나 [CreateIndex](https://docs.aws.amazon.com/kendra/latest/APIReference/API_CreateIndex.html) API를 직접 호출하여 인덱스를 생성할 수 있습니다. API에서 AWS Command Line Interface (AWS CLI) 또는 SDK를 사용할 수 있습니다. 인덱스를 만든 후 인덱스에 직접 또는 데이터 소스에서 문서를 추가할 수 있습니다.

인덱스를 생성하려면 인덱스가 액세스할 수 있도록 () 역할의 Amazon 리소스 이름 AWS Identity and Access Management (ARN IAM)을 제공해야 합니다 CloudWatch. 자세한 내용은 [인덱스에 대한IAM 역할](https://docs.aws.amazon.com/kendra/latest/dg/iam-roles.html#iam-roles-index)을 참조하세요.

다음 탭은를 사용하여 인덱스를 생성하는 절차와 AWS Management Console및 AWS CLI Python 및 Java SDKs를 사용하기 위한 코드 예제를 제공합니다.

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

**인덱스를 생성하려면**

1.  AWS Management Console에 로그인하고 [https://console.aws.amazon.com/kendra/](https://console.aws.amazon.com/kendra/) Amazon Kendra 콘솔을 엽니다.

1. **인덱스** 섹션에서 **인덱스 생성**을 선택합니다.

1. **인덱스 세부정보 지정** 페이지에서 인덱스 이름과 설명을 입력합니다.

1. **IAM 역할**에서 IAM 역할을 제공합니다. 역할을 찾으려면 계정에서 “kendra”라는 단어가 포함된 역할 중에서 선택하거나 다른 역할의 이름을 입력하세요. 역할에 필요한 권한에 대한 자세한 내용은 [인덱스에 대한IAM 역할](https://docs.aws.amazon.com/kendra/latest/dg/iam-roles.html#iam-roles-index)을 참조하세요.

1. **다음**을 선택합니다.

1. **사용자 액세스 제어 구성** 페이지에서 **다음**을 선택합니다. 인덱스를 만든 후 액세스 제어에 토큰을 사용하도록 인덱스를 업데이트할 수 있습니다. 자세한 내용은 [문서에 대한 액세스 제어](https://docs.aws.amazon.com/kendra/latest/dg/create-index-access-control.html)를 참조하세요.

1. **프로비저닝 세부 정보** 페이지에서 **생성**을 선택합니다.

1. 인덱스를 생성하는 데 시간이 걸릴 수 있습니다. 인덱스 목록을 확인하여 인덱스 생성 진행 상황을 확인하세요. 인덱스 상태가 `ACTIVE`가 되면 인덱스를 사용할 준비가 된 것입니다.

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

**인덱스를 생성하려면**

1. 다음 명령을 사용하여 인덱스를 생성합니다. 는 Amazon Kendra 작업을 실행할 수 있는 IAM 역할의 Amazon 리소스 이름(ARN)`role-arn`이어야 합니다. 자세한 내용은 [IAM 역할](https://docs.aws.amazon.com/kendra/latest/dg/iam-roles.html)을 참조하세요.

   이 명령은 Linux 및 macOS용으로 형식이 지정됩니다. Windows를 사용하는 경우 Unix 줄 연속 문자(\\)를 캐럿(^)으로 바꿉니다.

   ```
   aws kendra create-index \
    --name {{index name}} \
    --description "{{index description}}" \
    --role-arn arn:aws:iam::{{account ID}}:role/{{role name}}
   ```

1. 인덱스를 생성하는 데 시간이 걸릴 수 있습니다. 인덱스 상태를 확인하려면 `create-index`에서 반환한 인덱스 ID를 다음 명령과 함께 사용하세요. 인덱스 상태가 `ACTIVE`가 되면 인덱스를 사용할 준비가 된 것입니다.

   ```
   aws kendra describe-index \
    --index-id {{index ID}}
   ```

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

**인덱스를 생성하려면**
+ 코드 예제에서 다음 변수의 값을 입력합니다.
  + `description` - 생성 중인 인덱스에 대한 설명입니다. 이는 선택 사항입니다.
  + `index_name` - 생성 중인 인덱스의 이름입니다.
  + `role_arn`- Amazon Kendra APIs. 자세한 내용은 [IAM 역할](https://docs.aws.amazon.com/kendra/latest/dg/iam-roles.html)을 참조하세요.

  ```
  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 = "index-name"
  # Provide an optional description for the index
  description = "index description"
  # Provide the IAM role ARN required for indexes
  role_arn = "arn:aws:iam::${account id}:role/${role name}"
  
  try:
      index_response = kendra.create_index(
          Name = index_name,
          Description = description,
          RoleArn = 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
          )
          # If status is not CREATING, then quit
          status = index_description["Status"]
          print(" Creating index. Status: "+status)
          if status != "CREATING":
              break
          time.sleep(60)
  
  except  ClientError as e:
          print("%s" % e)
  
  print("Program ends.")
  ```

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

**인덱스를 생성하려면**
+ 코드 예제에서 다음 변수의 값을 입력합니다.
  + `description` - 생성 중인 인덱스에 대한 설명입니다. 이는 선택 사항입니다.
  + `index_name` - 생성 중인 인덱스의 이름입니다.
  + `role_arn`- Amazon Kendra APIs. 자세한 내용은 [IAM 역할](https://docs.aws.amazon.com/kendra/latest/dg/iam-roles.html)을 참조하세요.

  ```
  package com.amazonaws.kendra;
  
  import java.util.concurrent.TimeUnit;
  import software.amazon.awssdk.services.kendra.KendraClient;
  import software.amazon.awssdk.services.kendra.model.CreateIndexRequest;
  import software.amazon.awssdk.services.kendra.model.CreateIndexResponse;
  import software.amazon.awssdk.services.kendra.model.DescribeIndexRequest;
  import software.amazon.awssdk.services.kendra.model.DescribeIndexResponse;
  import software.amazon.awssdk.services.kendra.model.IndexStatus;
  
  
  public class CreateIndexExample {
  
      public static void main(String[] args) throws InterruptedException {
  
          String indexDescription = "Getting started index for Kendra";
          String indexName = "java-getting-started-index";
          String indexRoleArn = "arn:aws:iam::<your AWS account ID>:role/KendraRoleForGettingStartedIndex";
  
          System.out.println(String.format("Creating an index named %s", indexName));
          CreateIndexRequest createIndexRequest = CreateIndexRequest
              .builder()
              .description(indexDescription)
              .name(indexName)
              .roleArn(indexRoleArn)
              .build();
          KendraClient kendra = KendraClient.builder().build();
          CreateIndexResponse createIndexResponse = kendra.createIndex(createIndexRequest);
          System.out.println(String.format("Index response %s", createIndexResponse));
  
          String indexId = createIndexResponse.id();
  
          System.out.println(String.format("Waiting until the index with ID %s is created.", indexId));
          while (true) {
              DescribeIndexRequest describeIndexRequest = DescribeIndexRequest.builder().id(indexId).build();
              DescribeIndexResponse describeIndexResponse = kendra.describeIndex(describeIndexRequest);
              IndexStatus status = describeIndexResponse.status();
              if (status != IndexStatus.CREATING) {
                  break;
              }
  
              TimeUnit.SECONDS.sleep(60);
          }
  
          System.out.println("Index creation is complete.");
      }
  }
  ```

------

인덱스를 만든 후 인덱스에 문서를 추가합니다. 직접 추가하거나 정기적으로 인덱스를 업데이트하는 데이터 소스를 만들 수 있습니다.

**Topics**
+ [일괄 업로드를 사용하여 인덱스에 직접 문서 추가](in-adding-documents.md)
+ [인덱스에 자주 묻는 질문(FAQ) 추가](in-creating-faq.md)
+ [사용자 지정 문서 필드 만들기](custom-attributes.md)
+ [토큰을 사용하여 문서에 대한 사용자 액세스 제어](create-index-access-control.md)