

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

# 컬렉션 생성(CLI)
<a name="serverless-create-cli"></a>

이 섹션의 절차에 따라 AWS CLI를 사용하여 OpenSearch Serverless 컬렉션을 생성합니다.

**Topics**
+ [시작하기 전 준비 사항](#serverless-create-cli-before-you-begin)
+ [컬렉션 생성](#serverless-create-cli-creating)
+ [자동 시맨틱 보강 인덱스를 사용하여 컬렉션 생성](#serverless-create-cli-automatic-semantic-enrichment)

## 시작하기 전 준비 사항
<a name="serverless-create-cli-before-you-begin"></a>

를 사용하여 컬렉션을 생성하기 전에 다음 절차에 AWS CLI따라 컬렉션에 필요한 정책을 생성합니다.

**참고**  
다음 각 절차에서 컬렉션의 이름을 지정할 때 이름은 다음 기준을 충족해야 합니다.  
계정 및에 고유합니다. AWS 리전
소문자 a\$1z, 숫자 0\$19 및 하이픈(-)만 포함할 것
3\$132자 사이일 것

**컬렉션에 필요한 정책을 생성하려면**

1. 를 열고 다음 명령을 AWS CLI 실행하여 컬렉션의 의도한 이름과 일치하는 리소스 패턴으로 [암호화 정책을](serverless-encryption.md) 생성합니다.

   ```
   &aws opensearchserverless create-security-policy \
     --name policy name \
     --type encryption --policy "{\"Rules\":[{\"ResourceType\":\"collection\",\"Resource\":[\"collection\/collection name\"]}],\"AWSOwnedKey\":true}"
   ```

   예를 들어 컬렉션 **로그 애플리케이션의 이름을 지정하려는 경우 다음과 같은 암호화 정책을 생성할 수 있습니다.

   ```
   &aws opensearchserverless create-security-policy \
     --name logs-policy \
     --type encryption --policy "{\"Rules\":[{\"ResourceType\":\"collection\",\"Resource\":[\"collection\/logs-application\"]}],\"AWSOwnedKey\":true}"
   ```

   정책을 추가 컬렉션에 사용하려는 경우 `collection/logs*` 또는 `collection/*`과 같이 규칙을 더 광범위하게 만들 수 있습니다.

1. 다음 명령을 실행하여 컬렉션에 대해 [네트워크 정책](serverless-network.md)을 사용한 네트워크 설정을 구성합니다. 컬렉션을 생성한 후에 네트워크 정책을 생성해도 되지만, 네트워크 정책은 컬렉션보다 먼저 생성하는 것이 좋습니다.

   ```
   &aws opensearchserverless create-security-policy \
     --name policy name \
     --type network --policy "[{\"Description\":\"description\",\"Rules\":[{\"ResourceType\":\"dashboard\",\"Resource\":[\"collection\/collection name\"]},{\"ResourceType\":\"collection\",\"Resource\":[\"collection\/collection name\"]}],\"AllowFromPublic\":true}]"
   ```

   이전 **로그 애플리케이션 예시를 사용하여 다음과 같은 네트워크 정책을 생성할 수 있습니다.

   ```
   &aws opensearchserverless create-security-policy \
     --name logs-policy \
     --type network --policy "[{\"Description\":\"Public access for logs collection\",\"Rules\":[{\"ResourceType\":\"dashboard\",\"Resource\":[\"collection\/logs-application\"]},{\"ResourceType\":\"collection\",\"Resource\":[\"collection\/logs-application\"]}],\"AllowFromPublic\":true}]"
   ```

## 컬렉션 생성
<a name="serverless-create-cli-creating"></a>

다음 절차에서는 [CreateCollection](https://docs.aws.amazon.com/opensearch-service/latest/ServerlessAPIReference/API_CreateCollection.html) API 작업을 사용하여 `SEARCH` 또는 `TIMESERIES` 유형의 컬렉션을 생성합니다. 요청에 컬렉션 유형을 지정하지 않으면 기본값은 `TIMESERIES`입니다. 이러한 유형에 대한 자세한 설명은 [컬렉션 유형 선택](serverless-overview.md#serverless-usecase) 섹션을 참조하세요. *벡터 검색* 컬렉션을 만들려면 [벡터 검색 컬렉션 작업](serverless-vector-search.md)(을)를 참조하세요.

컬렉션이 로 암호화된 경우 AWS 소유 키`kmsKeyArn`는 ARN`auto`이 아닌 입니다.

**중요**  
컬렉션을 생성한 후에는 데이터 액세스 정책과 일치하지 않는 한 컬렉션에 액세스할 수 없습니다. 자세한 내용은 [Amazon OpenSearch Serverless를 위한 데이터 액세스 제어](serverless-data-access.md) 단원을 참조하십시오.

**컬렉션 생성**

1. [시작하기 전 준비 사항](#serverless-create-cli-before-you-begin)에서 설명하는 필수 정책을 생성했는지 확인합니다.

1. 다음 명령을 실행합니다. `type`에서 `SEARCH` 또는 `TIMESERIES`를 지정합니다.

   ```
   &aws opensearchserverless create-collection --name "collection name" --type collection type --description "description"
   ```

## 자동 시맨틱 보강 인덱스를 사용하여 컬렉션 생성
<a name="serverless-create-cli-automatic-semantic-enrichment"></a>

다음 절차에 따라 [자동 시맨틱 보강](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/serverless-semantic-enrichment.html)을 위해 구성된 인덱스를 사용하여 새 OpenSearch Serverless 컬렉션을 생성합니다. 이 절차에서는 OpenSearch Serverless [CreateIndex](https://docs.aws.amazon.com/opensearch-service/latest/ServerlessAPIReference/API_CreateIndex.html) API 작업을 사용합니다.

**자동 시맨틱 보강을 위해 인덱스가 구성된 새 컬렉션을 생성하려면**

다음 명령을 실행하여 컬렉션과 인덱스를 생성합니다.

```
&aws opensearchserverless create-index \
--region Region ID \
--id collection name --index-name index name \
--index-schema \
'mapping in json'
```

다음은 그 예입니다.

```
&aws opensearchserverless create-index \
--region us-east-1 \
--id conversation_history --index-name conversation_history_index \
--index-schema \ 
'{
    "mappings": {
        "properties": {
            "age": {
                "type": "integer"
            },
            "name": {
                "type": "keyword"
            },
            "user_description": {
                "type": "text"
            },
            "conversation_history": {
                "type": "text",
                "semantic_enrichment": {
                    "status": "ENABLED",
                    // Specifies the sparse tokenizer for processing multi-lingual text
                    "language_option": "MULTI-LINGUAL", 
                    // If embedding_field is provided, the semantic embedding field will be set to the given name rather than original field name + "_embedding"
                    "embedding_field": "conversation_history_user_defined" 
                }
            },
            "book_title": {
                "type": "text",
                "semantic_enrichment": {
                    // No embedding_field is provided, so the semantic embedding field is set to "book_title_embedding"
                    "status": "ENABLED",
                    "language_option": "ENGLISH"
                }
            },
            "abstract": {
                "type": "text",
                "semantic_enrichment": {
                    // If no language_option is provided, it will be set to English.
                    // No embedding_field is provided, so the semantic embedding field is set to "abstract_embedding"
                    "status": "ENABLED" 
                }
            }
        }
    }
}'
```