翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
コレクションを作成する (CLI)
このセクションの手順を使用して、 を使用して OpenSearch Serverless コレクションを作成します AWS CLI。
[開始する前に]
を使用してコレクションを作成する前に AWS CLI、次の手順を使用してコレクションに必要なポリシーを作成します。
注記
以下の手順のそれぞれで、コレクションの名前を指定する場合、その名前は次の基準を満たす必要があります。
-
アカウントと に固有である AWS リージョン
-
小文字の a~z、0~9 の数字、ハイフン (-) のみ含まれる
-
3~32 文字
コレクションに必要なポリシーを作成するには
-
を開き AWS CLI 、次のコマンドを実行して、コレクションの目的の名前と一致するリソースパターンを持つ暗号化ポリシーを作成します。
aws opensearchserverless create-security-policy \ --name
policy name
\ --type encryption --policy "{\"Rules\":[{\"ResourceType\":\"collection\",\"Resource\":[\"collection\/collection name
\"]}],\"AWSOwnedKey\":true}"例えば、コレクションに「logs-application」という名前を付ける場合は、次のような暗号化ポリシーを作成します。
aws opensearchserverless create-security-policy \ --name logs-policy \ --type encryption --policy "{\"Rules\":[{\"ResourceType\":\"collection\",\"Resource\":[\"collection\/logs-application\"]}],\"AWSOwnedKey\":true}"
このポリシーを別のコレクションにも使用する場合は、
collection/logs*
やcollection/*
のようにルールを拡張しておくことができます。 -
次のコマンドを実行して、ネットワークポリシーを使用してコレクションのネットワーク設定を行います。ネットワークポリシーは、コレクションを作成した後でも作成できますが、事前に作成することをお勧めします。
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}]"前述の「logs-application」の例を使用すると、次のネットワークポリシーを作成できます。
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}]"
コレクションの作成
次の手順では、CreateCollection API アクションを使用して、タイプ SEARCH
または のコレクションを作成しますTIMESERIES
。リクエストでコレクションタイプを指定しない場合、デフォルトは TIMESERIES
です。これらのタイプの詳細については、「」を参照してくださいコレクションタイプを選択する。ベクター検索コレクションを作成するには、「ベクトル検索コレクションの使用」を参照してください。
コレクションが で暗号化されている場合 AWS 所有のキー、 kmsKeyArn
は ARN auto
ではなく です。
重要
コレクション作成後は、データアクセスポリシーと一致しない限りアクセスできません。詳細については、「Amazon OpenSearch Serverless のデータアクセスコントロール」を参照してください。
コレクションを作成するには
-
「」で説明されている必須ポリシーを作成したことを確認します[開始する前に]。
-
以下のコマンドを実行してください。には、
SEARCH
またはtype
を指定しますTIMESERIES
。aws opensearchserverless create-collection --name "
collection name
" --typecollection type
--description "description
"
自動セマンティックエンリッチメントインデックスを使用したコレクションの作成
以下の手順を使用して、自動セマンティックエンリッチメント用に設定されたインデックスを持つ新しい OpenSearch Serverless コレクションを作成します。この手順では、OpenSearch Serverless CreateIndex API アクションを使用します。
自動セマンティックエンリッチメント用に設定されたインデックスを使用して新しいコレクションを作成するには
次のコマンドを実行して、コレクションとインデックスを作成します。
aws opensearchserverless create-index \ --region
Region ID
\ --idcollection name
--index-nameindex 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" } } } } }'