

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 特色為搜尋結果
<a name="featured-results"></a>

**注意**  
功能支援會因索引類型和正在使用的搜尋 API 而有所不同。若要查看您正在使用的索引類型和搜尋 API 是否支援此功能，請參閱[索引類型](https://docs.aws.amazon.com/kendra/latest/dg/hiw-index-types.html)。

當您的使用者發出特定查詢時，您可以在搜尋結果中特徵化特定文件。這有助於讓您的使用者更明顯可見結果。精選結果與一般結果清單分開，並顯示在搜尋頁面頂端。您可以嘗試為不同的查詢提供不同的文件，或確保某些文件獲得應得的可見性。

您可以將特定查詢映射到結果中 的 特定文件。如果查詢包含完全相符的項目，則會在搜尋結果中顯示一或多個特定文件。

例如，您可以指定，如果您的使用者發出查詢「新產品 2023」，請選取搜尋結果頁面頂端名為「最新消息」和「即將推出」的文件。這有助於確保新產品上的這些文件獲得應有的可見性。

Amazon Kendra 如果已為搜尋結果頁面頂端的 功能選取結果，則 不會複製搜尋結果。如果特徵結果已超過所有其他結果，則特徵結果不會再次排名為第一個結果。

若要特徵化特定結果，您必須使用查詢中包含的關鍵字或片語來指定完整文字查詢的完全相符項目，而非部分相符項目。例如，如果您只在特色結果集中指定查詢 'Kendra'，像是「Kendra 如何以語意排列結果？」的查詢 不會轉譯特色結果。精選結果是針對特定查詢所設計，而不是範圍太廣的查詢。 Amazon Kendra 自然處理關鍵字類型查詢，以對搜尋結果中最有用的文件進行排名，避免根據簡單關鍵字過度描述結果。

如果您的使用者經常使用某些查詢，則可以為特色結果指定這些查詢。例如，如果您使用 [Amazon Kendra Analytics](https://docs.aws.amazon.com/kendra/latest/dg/search-analytics.html) 查看您的熱門查詢，並找到特定查詢，例如「Kendra 如何以語義方式排名結果？」 和 'kendra 語意搜尋' 經常使用，因此這些查詢對於為 指定名為 'Amazon Kendra search 101' 的文件可能很有用。

Amazon Kendra 會將特色結果的查詢視為不區分大小寫。 會將查詢 Amazon Kendra 轉換為小寫，並將結尾空白字元取代為單一空格。 Amazon Kendra 當您指定特色結果的查詢時，所有其他字元會與其相同。

您可以使用 [CreateFeaturedResultsSet](https://docs.aws.amazon.com/kendra/latest/APIReference/API_CreateFeaturedResultsSet.html) API，建立一組映射至特定查詢的精選結果。如果您使用 主控台，請選取您的索引，然後在導覽功能表中選取**特色結果**，以建立特色結果集。每個索引最多可以建立 50 組特色結果、每個集最多要特色化四份文件，以及每個特色結果集最多 49 個查詢文字。您可以聯絡 [Support](https://aws.amazon.com/contact-us/) 來請求提高這些限制。

您可以跨多組特色結果選取相同的文件。不過，您不得跨多個集使用相同的完全相符查詢文字。您為特徵結果指定的查詢在每個索引的特徵結果集必須是唯一的。

在選取最多四個特色文件時，您可以安排文件的順序。如果您使用 API，您列出特色文件的順序與特色結果中顯示的順序相同。如果您使用 主控台，當您在結果中選取 的 文件時，可以直接拖放文件順序。

設定特色結果時，仍會遵守某些使用者和群組可存取某些文件，而其他使用者和群組無法存取的存取控制。對於使用者內容篩選也是如此。例如，使用者 A 屬於 'Interns' 公司群組，不應存取公司秘密上的文件。如果使用者 A 輸入具有公司秘密文件的查詢，則使用者 A 不會在其結果中看到此文件。搜尋結果頁面上的任何其他結果也是如此。您也可以使用標籤來控制對特色結果集的存取，這是 Amazon Kendra 您控制存取的資源。

以下是建立一組精選結果的範例，其中包含「新產品 2023」、「新產品可用」映射至名為「最新消息」(doc-id-1) 和「即將推出」(doc-id-2) 的文件。

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

```
aws kendra create-featured-results-set \
 --featured-results-set-name 'New product docs to feature' \
 --description "Featuring What's new and Coming soon docs" \
 --index-id index-id \
 --query-texts 'new products 2023' 'new products available' \
 --featured-documents '{"Id":"doc-id-1", "Id":"doc-id-2"}'
```

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

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

kendra = boto3.client("kendra")

print("Create a featured results set.")

# Provide a name for the featured results set
featured_results_name = "New product docs to feature"
# Provide an optional decription for the featured results set
description = "Featuring What's new and Coming soon docs"
# Provide the index ID for the featured results set
index = "index-id"
# Provide a list of query texts for the featured results set
queries = ['new products 2023', 'new products available']
# Provide a list of document IDs for the featured results set
featured_doc_ids = [{"Id":"doc-id-1"}, {"Id":"doc-id-2"}]

try:
    featured_results_set_response = kendra.create_featured_results_set(
        FeaturedResultsSetName = featured_results_name,
        Decription = description,
        Index = index,
        QueryTexts = queries,
        FeaturedDocuments = featured_doc_ids
    )

    pprint.pprint(featured_results_set_response)

    featured_results_set_id = featured_results_set_response["FeaturedResultsSetId"]

    while True:
        # Get the details of the featured results set, such as the status
        featured_results_set_description = kendra.describe_featured_results_set(
            Id = featured_results_set_id
        )
        status = featured_results_set_description["Status"]
        print(" Featured results set status: "+status)
            
except  ClientError as e:
        print("%s" % e)

print("Program ends.")
```

------