

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# コードなしで検索エクスペリエンスを構築する
<a name="deploying-search-experience-no-code"></a>

フロントエンドコードなしで Amazon Kendra 検索アプリケーションを構築およびデプロイできます。 Amazon Kendra *Experience Builder* は、数回のクリックで完全に機能する検索アプリケーションの構築とデプロイを支援し、すぐに検索を開始できます。検索ページをカスタム設計し、検索を調整して、ユーザーのニーズに合わせてエクスペリエンスを調整できます。 は、検索ページの一意で完全にホストされたエンドポイント URL Amazon Kendra を生成して、ドキュメントやFAQsの検索を開始します。検索エクスペリエンスの概念実証をすばやく構築し、他のユーザーと共有できます。

ビルダーで使用可能な検索エクスペリエンステンプレートを使用して、検索をカスタマイズします。他のユーザーを招待して検索エクスペリエンスを構築したり、チューニング目的で検索結果を評価したりできます。ユーザーが検索を開始する準備ができたら、セキュリティで保護されたエンドポイント URL を共有するだけです。

## 検索 Experience Builder の仕組み
<a name="how-search-experience-builder-works"></a>

検索エクスペリエンスを構築するための全体的なプロセスを次に示します。

1. 検索エクスペリエンスを作成するには、名前、説明を指定し、検索エクスペリエンスに使用するデータソースを選択します。

1. でユーザーとグループのリストを設定し AWS IAM アイデンティティセンター 、検索エクスペリエンスへのアクセス権を割り当てます。自分をエクスペリエンスのオーナーとして含めます。詳細については、「[検索ページへのアクセスを提供する](#access-search-experience)」を参照してください。

1.  Amazon Kendra Experience Builder を開いて、検索ページを設計および調整します。独自の編集アクセス権または表示検索アクセス権を割り当てた他のユーザーと、検索エクスペリエンスのエンドポイント URL を共有できます。

[CreateExperience](https://docs.aws.amazon.com/kendra/latest/APIReference/API_CreateExperience.html) API を呼び出して、検索エクスペリエンスを作成および設定します。コンソールを使用する場合は、インデックスを選択し、ナビゲーションメニューで **[エクスペリエンス]** を選択してエクスペリエンスを設定します。

## 検索エクスペリエンスを設計してチューニングする
<a name="design-tune-search-experience"></a>

検索エクスペリエンスを作成して設定したら、エンドポイント URL を使用して検索エクスペリエンスを開き、編集アクセス権を持つ所有者としての検索のカスタマイズを開始します。検索ボックスにクエリを入力し、サイドパネルの編集オプションを使用して検索をカスタマイズし、ページに適用する方法を確認します。公開する準備ができたら、**[Publish]** (公開) をクリックします。**[Switch to live view]** (ライブビューに切り替える) をクリックして、検索ページの最新公開バージョンを表示し、**[Switch to build mode]** (構築モードに切り替える) をクリックして、検索ページを編集またはカスタマイズすることもできます。

以下は、検索エクスペリエンスをカスタマイズする方法です。

### フィルター
<a name="search-experience-filter"></a>

ファセット検索を追加するか、ドキュメント属性でフィルタリングします。これには、カスタム属性が含まれます。独自の設定済みのメタデータフィールドを使用して、フィルターを追加できます。例えば、各都市のカテゴリでファセット検索を行うには、すべての都市カテゴリを含む `_category` カスタムドキュメント属性を使用します。

### 提案する回答
<a name="search-experience-suggested-answer"></a>

機械学習で生成された回答をユーザーのクエリに追加します。たとえば、*「本コースはどのくらい難しいですか?*」と入力します。 は、コースの難易度を参照し、最も関連性の高い回答を提案するすべてのドキュメントで、最も関連性の高いテキストを取得 Amazon Kendra できます。

### よくある質問
<a name="search-experience-faq"></a>

よくある質問への回答を得るには、よくある質問ドキュメントを追加します。たとえば、*「本コースを完了するのに何時間かかりますか?*」と入力します。この質問に対する回答を含む FAQ ドキュメントを使用して、正しい回答を返す Amazon Kendra ことができます。

### 並べ替え
<a name="search-experience-sort"></a>

検索結果のソートを追加して、ユーザーが関連性、作成時刻、最終更新時刻、その他のソート基準で結果を整理できるようにします。

### ドキュメント
<a name="search-experience-documents"></a>

検索ページでのドキュメントまたは検索結果の表示方法を設定します。ページに表示する結果の数を構成したり、ページ番号などのページ割りを追加したり、ユーザーフィードバックボタンを有効にしたり、検索結果にドキュメントメタデータフィールドを表示する方法を調整したりできます。

### Language
<a name="search-experience-language"></a>

言語を選択して、選択した言語で検索結果またはドキュメントをフィルタリングします。

### 検索ボックス
<a name="search-experience-search-box"></a>

検索ボックスのサイズとプレースホルダテキストを設定し、クエリ提案を有効にします。

### 関連性チューニング
<a name="search-experience-relevance-tuning"></a>

ドキュメントメタデータフィールドにブーストを追加して、ユーザーがドキュメントを検索するときにこれらのフィールドに重みを付けます。1 から始まり、10 に徐々に増加する重みを追加できます。テキスト、日付、および数値フィールドの種類をブーストできます。例えば、`_last_updated_at` および `_created_at` の他のフィールドよりも重い、または重要な重みまたは重要度を付けるには、これらのフィールドの重要度に応じて 1～10 の重みを指定します。検索アプリケーションまたはエクスペリエンスごとに異なる関連性チューニング設定を適用できます。

## 検索ページへのアクセスを提供する
<a name="access-search-experience"></a>

検索エクスペリエンスには IAM Identity Center からアクセスします。検索エクスペリエンスを設定するときは、Identity Center ディレクトリにリストされている他のユーザーに Amazon Kendra 検索ページへのアクセスを許可します。それらのユーザーは、IAM Identity Center で自身の資格情報を使用してサインインし検索ページにアクセスするように導く、E メールを受け取ります。IAM Identity Center は組織レベルまたは AWS Organizationsのアカウント所有者レベルでセットアップする必要があります。IAM Identity Center の詳細については、「[Getting started with IAM Identity Center](https://docs.aws.amazon.com/kendra/latest/dg/getting-started-aws-sso.html)」を参照してください。

検索エクスペリエンスの IAM Identity Center でユーザーアイデンティティを有効にして、API またはコンソールを使用し、*閲覧者*または*所有者*アクセス許可を割り当てます。
+ **閲覧者**: クエリを発行し、検索に関連する提案された回答を受け取り、フィードバックを Amazon Kendra に提供して、検索を改善し続けることができます。
+ **所有者**: 検索ページのデザインをカスタマイズし、検索をチューニングし、検索アプリケーションを*閲覧者*として使用できます。コンソールで閲覧者へのアクセスを無効にすることは、現在サポートされていません。

他のユーザーに検索エクスペリエンスへのアクセスを割り当てるには、まず [ExperienceConfiguration](https://docs.aws.amazon.com/kendra/latest/APIReference/API_ExperienceConfiguration.html) オブジェクトを使用して、IAM Identity Center でユーザー ID を自分の Amazon Kendra エクスペリエンスでアクティブ化します。ユーザー名や E メールアドレスなど、ユーザーの識別子を含むフィールド名を指定します。次に、[AssociateEntitiesToExperience API](https://docs.aws.amazon.com/kendra/latest/APIReference/API_AssociateEntitiesToExperience.html) を使用して、ユーザーのリストに検索エクスペリエンスへのアクセス権を付与し、[AssociatePersonasToEntities](https://docs.aws.amazon.com/kendra/latest/APIReference/API_AssociatePersonasToEntities.html) API を使用して、アクセス許可を*閲覧者*または*所有者*に定義します。[EntityConfiguration](https://docs.aws.amazon.com/kendra/latest/APIReference/API_EntityConfiguration.html) オブジェクトを使用して各ユーザーまたはグループを指定し、[EntityPersonaConfiguraton](https://docs.aws.amazon.com/kendra/latest/APIReference/API_EntityPersonaConfiguration.html) オブジェクトを使用してそのユーザーまたはグループが*閲覧者*か*所有者*かを指定します。

コンソールを使用して他のユーザーに検索エクスペリエンスへのアクセス権を割り当てるには、まずエクスペリエンスを作成し、自分のアイデンティティと自分が所有者であることを確認する必要があります。その後、他のユーザーまたはグループを閲覧者または所有者として割り当てることができます。コンソールで、インデックスを選択し、ナビゲーションメニューの **[Experiences]** (エクスペリエンス) を選択します。エクスペリエンスを作成したら、リストからエクスペリエンスを選択できます。**[Access management]** (アクセス管理) に移動し、ユーザーまたはグループを閲覧者または所有者として割り当てます。

## 検索エクスペリエンスの設定
<a name="config-search-experience"></a>

次に、検索エクスペリエンスを構成または作成する例を示します。

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

**Amazon Kendra 検索エクスペリエンスを作成するには**

1. 左側のナビゲーションペインの **[Indexes]** (インデックス) で、**[Experiences]** (エクスペリエンス)、**[Create experiences]** (エクスペリエンスの作成) の順に選択します。

1. **[Configure experience]** (エクスペリエンスの設定) ページで、エクスペリエンスの名前と説明を入力し、コンテンツソースを選択し、エクスペリエンスの IAM ロールを選択します。IAM ロールの詳細については、[Amazon Kendra 「エクスペリエンスの IAM ロール](https://docs.aws.amazon.com/kendra/latest/dg/iam-roles.html)」を参照してください。

1. **[ディレクトリからアイデンティティを確認する]** ページで、E メールなどのユーザー ID を選択します。Identity Center ディレクトリがない場合、フルネームと E メールを入力するだけで、Identity Center ディレクトリを作成できます。これには、エクスペリエンスのユーザーとしてのユーザーも含まれ、所有者のアクセス権が自動的に割り当てられます。

1. **[Review to open Experience Builder]** (確認してエクスペリエンスビルダーを開く) ページで、設定の詳細を確認し、**[Create experience and open Experience Builder]** (エクスペリエンスを作成し、エクスペリエンスビルダーを開く) をクリックして、検索ページの編集を開始します。

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

** Amazon Kendra エクスペリエンスの作成方法**

```
aws kendra create-experience \
 --name {{experience-name}} \
 --description {{"experience description"}} \
 --index-id {{index-id}} \
 --role-arn {{arn:aws:iam::account-id:role/role-name}} \
 --configuration '{"ExperienceConfiguration":[{"ContentSourceConfiguration":{"DataSourceIds":["data-source-1","data-source-2"]}, "UserIdentityConfiguration":"identity attribute name"}]}' 

aws kendra describe-experience \
 --endpoints {{experience-endpoint-URL(s)}}
```

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

** Amazon Kendra エクスペリエンスの作成方法**

```
import boto3
from botocore.exceptions import ClientError
import pprint
import time

kendra = boto3.client("kendra")

print("Create an experience.")

# Provide a name for the experience
name = "experience-name"
# Provide an optional description for the experience
description = "experience description"
# Provide the index ID for the experience
index_id = "index-id"
# Provide the IAM role ARN required for Amazon Kendra experiences
role_arn = "arn:aws:iam::${account-id}:role/${role-name}"
# Configure the experience
configuration = {"ExperienceConfiguration":
        [{
            "ContentSourceConfiguration":{"DataSourceIds":["data-source-1","data-source-2"]},
            "UserIdentityConfiguration":"identity attribute name"
        }]
    }

try:
    experience_response = kendra.create_experience(
        Name = name,
        Description = description,
        IndexId = index_id,
        RoleArn = role_arn,
        Configuration = configuration
    )

    pprint.pprint(experience_response)

    experience_endpoints = experience_response["Endpoints"]

    print("Wait for Amazon Kendra to create the experience.")

    while True:
        # Get the details of the experience, such as the status
        experience_description = kendra.describe_experience(
            Endpoints = experience_endpoints
        )
        status = experience_description["Status"]
        print(" Creating experience. Status: "+status)
        time.sleep(60)
        if status != "CREATING":
            break

except  ClientError as e:
        print("%s" % e)

print("Program ends.")
```

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

**を作成するには Amazon Kendra**

```
package com.amazonaws.kendra;

import java.util.concurrent.TimeUnit;
import software.amazon.awssdk.services.kendra.KendraClient;
import software.amazon.awssdk.services.kendra.model.CreateExperienceRequest;
import software.amazon.awssdk.services.kendra.model.CreateExperienceResponse;
import software.amazon.awssdk.services.kendra.model.DescribeExperienceRequest;
import software.amazon.awssdk.services.kendra.model.DescribeExperienceResponse;
import software.amazon.awssdk.services.kendra.model.ExperienceStatus;


public class CreateExperienceExample {

    public static void main(String[] args) throws InterruptedException {
        System.out.println("Create an experience");
        
        String experienceName = "experience-name";
        String experienceDescription = "experience description";
        String indexId = "index-id";
        String experienceRoleArn = "arn:aws:iam::account-id:role/role-name";

        KendraClient kendra = KendraClient.builder().build();
        
        CreateExperienceRequest createExperienceRequest = CreateExperienceRequest 
            .builder()
            .name(experienceName)
            .description(experienceDescription)
            .roleArn(experienceRoleArn)
            .configuration(
                ExperienceConfiguration
                    .builder()
                    .contentSourceConfiguration(
                        ContentSourceConfiguration(
                            .builder()
                            .dataSourceIds("data-source-1","data-source-2")
                            .build()
                        )
                    )
                    .userIdentityConfiguration(
                        UserIdentityConfiguration(
                            .builder()
                            .identityAttributeName("identity-attribute-name")
                            .build()
                        )
                    ).build()
            ).build();
        
        CreateExperienceResponse createExperienceResponse = kendra.createExperience(createExperienceRequest);
        System.out.println(String.format("Experience response %s", createExperienceResponse));

        String experienceEndpoints = createExperienceResponse.endpoints();

        System.out.println(String.format("Wait for Kendra to create the experience.", experienceEndpoints));
        while (true) {
            DescribeExperienceRequest describeExperienceRequest = DescribeExperienceRequest.builder().endpoints(experienceEndpoints).build();
            DescribeExperienceResponse describeEpxerienceResponse = kendra.describeExperience(describeExperienceRequest);
            ExperienceStatus status = describeExperienceResponse.status();
            TimeUnit.SECONDS.sleep(60);
            if (status != ExperienceStatus.CREATING) {
                break;
            }
        }

        System.out.println("Experience creation is complete.");
    }
}
```

------