

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 如何 Amazon Kendra 运作
<a name="how-it-works"></a>

Amazon Kendra 为您的应用程序提供搜索和检索增强生成 (RAG) 功能。它可以直接为您的文档编制索引，也可以从第三方文档存储库编制索引，并智能地向用户提供相关信息。您可以使用 Amazon Kendra 为各种类型的文档创建可更新的索引。有关支持的文档类型的列表 Amazon Kendra，请参阅[文档类型](https://docs.aws.amazon.com/kendra/latest/dg/index-document-types.html)。

Amazon Kendra 与其他服务集成。您可以将 Amazon Kendra GenAI 企业版索引连接到 [Amazon Q Business](https://docs.aws.amazon.com/amazonq/latest/qbusiness-ug/what-is.html) 和 [Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-bedrock.html) 来创建 RAG 聊天解决方案。或者，你可以为[Amazon Lex 聊天机器人](https://docs.aws.amazon.com/lexv2/latest/dg/faq-bot-kendra-search.html)提供 Amazon Kendra 搜索功能，为用户的问题提供有用的答案。您也可以使用[Amazon Simple Storage Service 存储桶](https://docs.aws.amazon.com/kendra/latest/dg/data-source-s3.html)作为数据源， Amazon Kendra 以连接您的文档并为其编制索引。

Amazon Kendra 包含以下组件：
+ 用于存储您的文档并使其可搜索的[https://docs.aws.amazon.com//kendra/latest/dg/create-index.html](https://docs.aws.amazon.com//kendra/latest/dg/create-index.html)。
+ 用于存储您的文档并将 Amazon Kendra 连接到的[https://docs.aws.amazon.com/kendra/latest/dg/data-source.html](https://docs.aws.amazon.com/kendra/latest/dg/data-source.html)。您可以自动将数据源与 Amazon Kendra 索引同步，以便您的索引与源存储库保持同步。
+ 一个将文档直接添加到索引的[https://docs.aws.amazon.com/kendra/latest/dg/in-adding-documents.html](https://docs.aws.amazon.com/kendra/latest/dg/in-adding-documents.html)。
+ 一个在给定输入查询后可检索相关段落或文本摘录的[https://docs.aws.amazon.com/kendra/latest/APIReference/API_Retrieve.html](https://docs.aws.amazon.com/kendra/latest/APIReference/API_Retrieve.html)。
+ 一个在给定输入查询后会对索引进行搜索的[https://docs.aws.amazon.com/kendra/latest/APIReference/API_Query.html](https://docs.aws.amazon.com/kendra/latest/APIReference/API_Query.html)。

您可以 Amazon Kendra 通过控制台或 API 使用。您可以创建、更新和删除索引。删除索引会删除其所有数据源连接器，并从中永久删除您的所有文档信息 Amazon Kendra。

**Topics**
+ [Amazon Kendra 中的索引](hiw-index.md)
+ [文档](hiw-documents.md)
+ [数据来源](hiw-data-source.md)
+ [查询](hiw-query.md)
+ [标签](tagging.md)

# Amazon Kendra 中的索引
<a name="hiw-index"></a>

索引保存文档的内容，其结构使文档可搜索。本部分提供受支持的索引类型和索引功能的概览。

**Topics**
+ [Amazon Kendra 中的索引类型](hiw-index-types.md)
+ [在 Amazon Kendra 中向索引中添加文档](hiw-index-adding-docs.md)
+ [使用 Amazon Kendra 保留或常用文档字段](index-reserved-fields-hiw.md)
+ [从 Amazon Kendra 中的索引中检索响应](index-searching.md)

# Amazon Kendra 中的索引类型
<a name="hiw-index-types"></a>

Amazon Kendra 有三种索引类型：GenAI 企业版索引、企业版索引和开发者版索引。以下各部分介绍了每种索引的功能。

**Topics**
+ [Amazon Kendra GenAI 企业版索引](#kendra-gen-ai-index)
+ [Amazon Kendra 企业版索引](#kendra-enterprise-index)
+ [Amazon Kendra 开发人员版索引](#kendra-developer-index)

## Amazon Kendra GenAI 企业版索引
<a name="kendra-gen-ai-index"></a>

Amazon Kendra GenAI 企业版索引为检索 API 操作和检索增强生成（RAG）使用案例提供最高的准确性。它采用最新的信息检索技术，如混合搜索（关键字和向量）、语义嵌入和重排序模型，并且已经在各种数据集上进行了测试。与 Amazon Kendra 开发人员版和 Amazon Kendra 企业版索引相比，查询 API 操作为 Amazon Kendra GenAI 企业版索引提供类似的准确性。

Amazon Kendra GenAI 企业版索引可让您的索引数据在生成人工智能服务之间 AWS 移动。借助此功能，您可以无缝地重复使用您的投资，而不必重建索引。您可以在 [Amazon Bedrock 知识库](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base.html)中将其用作托管式检索器，并将其与 Amazon Bedrock 工具（例如代理和提示流程）集成，以构建高级人工智能助手。您也可以将其与 [Amazon Q Business](https://docs.aws.amazon.com/amazonq/latest/qbusiness-ug/what-is.html) 结合使用，以构建完全托管式数字助手。

与其他两种索引类型相比，Amazon Kendra GenAI 企业版索引提供的容量单位更小、更精细，起始价格也更低。这有助于您更有效地利用容量。

**注意**  
为了获得最佳体验和准确性，我们建议您选择 Amazon Kendra GenAI 企业版索引。

**Topics**
+ [支持的功能](#kendra-gen-ai-index-features)
+ [限制](#genai-index-limitations)

### 支持的功能
<a name="kendra-gen-ai-index-features"></a>

如果您在 RAG 使用案例中使用[检索](https://docs.aws.amazon.com/kendra/latest/APIReference/API_Retrieve.html) API 操作，则 Amazon Kendra GenAI 企业版索引支持以下功能：
+ **全面支持** – [置信度分数存储桶](https://docs.aws.amazon.com/kendra/latest/APIReference/API_QueryResultItem.html#Kendra-Type-QueryResultItem-ScoreAttributes)、[筛选](https://docs.aws.amazon.com/kendra/latest/dg/filtering.html)、[分面](https://docs.aws.amazon.com/kendra/latest/dg/filtering.html#search-facets)、[相关性调试](https://docs.aws.amazon.com/kendra/latest/dg/tuning.html)、[自定义文档富集](https://docs.aws.amazon.com/kendra/latest/dg/custom-document-enrichment.html)、[自定义元数据](https://docs.aws.amazon.com/kendra/latest/dg/custom-attributes.html)以及[调整查询容量和文档容量](https://docs.aws.amazon.com/kendra/latest/dg/adjusting-capacity.html)。
+ **部分支持** – [数据来源连接器](https://docs.aws.amazon.com/kendra/latest/dg/data-source.html)和[用户上下文筛选](https://docs.aws.amazon.com/kendra/latest/dg/user-context-filter.html)。有关部分支持的功能的更多信息，请参阅[限制](https://docs.aws.amazon.com/kendra/latest/dg/hiw-index-types.html#genai-index-limitations)。

如果您在搜索使用案例中使用[查询](https://docs.aws.amazon.com/kendra/latest/APIReference/API_Query.html) API 操作，则 Amazon Kendra GenAI 企业版索引支持以下功能：
+ **全面支持** – [文档排名](https://docs.aws.amazon.com/kendra/latest/dg/search-service-rerank.html)、[提取式问答](https://docs.aws.amazon.com/kendra/latest/dg/searching-example.html)、[置信度分数存储桶](https://docs.aws.amazon.com/kendra/latest/APIReference/API_QueryResultItem.html#Kendra-Type-QueryResultItem-ScoreAttributes)、[筛选](https://docs.aws.amazon.com/kendra/latest/dg/filtering.html)、[分面](https://docs.aws.amazon.com/kendra/latest/dg/filtering.html#search-facets)、[排序](https://docs.aws.amazon.com/kendra/latest/dg/tuning-sorting-responses.html#sorting-responses)、[折叠和展开查询结果](https://docs.aws.amazon.com/kendra/latest/dg/expand-collapse-query-results.html)、[索引浏览](https://docs.aws.amazon.com/kendra/latest/dg/browsing.html)、[Boolean 查询](https://docs.aws.amazon.com/kendra/latest/dg/searching-example.html#searching-index-query-syntax)、[完全匹配](https://docs.aws.amazon.com/kendra/latest/dg/searching-example.html#searching-index-query-syntax)、[通配符查询](https://docs.aws.amazon.com/kendra/latest/dg/searching-example.html#searching-index-query-syntax)、[查询建议](https://docs.aws.amazon.com/kendra/latest/dg/query-suggestions.html)、[查询拼写检查器](https://docs.aws.amazon.com/kendra/latest/dg/query-spell-check.html)、[相关性调试](https://docs.aws.amazon.com/kendra/latest/dg/tuning.html)、[增量学习](https://docs.aws.amazon.com/kendra/latest/dg/submitting-feedback.html)、[自定义文档富集](https://docs.aws.amazon.com/kendra/latest/dg/custom-document-enrichment.html)、[自定义元数据](https://docs.aws.amazon.com/kendra/latest/dg/custom-attributes.html)、[调整查询容量和文档容量](https://docs.aws.amazon.com/kendra/latest/dg/adjusting-capacity.html)以及[搜索体验](https://docs.aws.amazon.com/kendra/latest/dg/deploying.html)。
+ **部分支持** – [数据来源连接器](https://docs.aws.amazon.com/kendra/latest/dg/data-source.html)和[用户上下文筛选](https://docs.aws.amazon.com/kendra/latest/dg/user-context-filter.html)。有关部分支持的功能的更多信息，请参阅[限制](https://docs.aws.amazon.com/kendra/latest/dg/hiw-index-types.html#kendra-gen-ai-index)。

### 限制
<a name="genai-index-limitations"></a>

以下内容概述了 Amazon Kendra GenAI 企业版索引的已知限制：
+ Amazon Kendra GenAI 企业版索引仅在美国东部（弗吉尼亚州北部）和美国西部（俄勒冈州）提供。
+ Amazon Kendra GenAI 企业版索引仅支持英语内容。
+ Amazon Kendra GenAI 企业版索引仅支持 v2.0 Amazon Kendra 数据来源连接器。
+ 在 Amazon Kendra GenAI 企业版索引中，您只能使用[用户属性](https://docs.aws.amazon.com/kendra/latest/dg/user-context-filter.html#context-filter-attribute)按用户上下文筛选搜索结果。
+ Amazon Kendra GenAI 企业版索引不支持对文档的[基于令牌的用户访问控制](https://docs.aws.amazon.com/kendra/latest/dg/create-index-access-control.html)或[基于用户 ID 和组的用户访问控制](https://docs.aws.amazon.com/kendra/latest/dg/user-context-filter.html#context-filter-user-incl-datasources)。
+ 亚马逊 Kendra GenAI 企业版索引的 [CreateAccessControlConfiguration](https://docs.aws.amazon.com/kendra/latest/APIReference/API_CreateAccessControlConfiguration.html)API 操作已禁用。
+ 如果您结合使用 Amazon Kendra GenAI 企业版索引和 Amazon Q Business，请注意以下有关控制最终用户对文档访问权限的事项：

  Amazon Q Business 使用用户电子邮件 ID 来确定最终用户对索引中文档的访问权限。当您将 Amazon Kendra 索引连接到时 Amazon Q Business，会将用户的识别电子邮件ID中 Amazon Q Business 继到Amazon Kendra，以便为最终用户启用文档筛选。如果连接到您的 Amazon Kendra 索引的数据源不使用基于电子邮件ID的文档筛选，或者电子邮件ID不存在，则只能从公共文档 Amazon Q Business 生成响应。

## Amazon Kendra 企业版索引
<a name="kendra-enterprise-index"></a>

Amazon Kendra 企业版索引提供语义搜索功能，并提供适用于生产工作负载的高可用性服务。

**Topics**
+ [支持的功能](#kendra-ent-index-features)
+ [限制](#ent-index-limitations)

### 支持的功能
<a name="kendra-ent-index-features"></a>

如果您在 RAG 使用案例中使用[检索](https://docs.aws.amazon.com/kendra/latest/APIReference/API_Retrieve.html) API 操作，那么 Amazon Kendra 企业版索引支持以下功能：使用[高级查询语法](https://docs.aws.amazon.com/kendra/latest/dg/searching-example.html#searching-index-query-syntax)进行查询、对查询使用[建议的拼写更正](https://docs.aws.amazon.com/kendra/latest/dg/query-spell-check.html)、[分面](https://docs.aws.amazon.com/kendra/latest/dg/filtering.html#search-facets)、自动完成搜索查询的[查询建议](https://docs.aws.amazon.com/kendra/latest/dg/query-suggestions.html)以及[增量学习](https://docs.aws.amazon.com/kendra/latest/dg/submitting-feedback.html)。

如果您在搜索使用案例中使用[查询](https://docs.aws.amazon.com/kendra/latest/APIReference/API_Query.html) API 操作，则 Amazon Kendra 企业版索引支持所有功能。

### 限制
<a name="ent-index-limitations"></a>

以下内容概述了 Amazon Kendra 企业版索引的已知限制：
+ 如果您使用的是 Amazon Kendra 企业版索引 Amazon Q Business，请注意以下有关控制最终用户访问文档的注意事项：

  Amazon Q Business 使用用户电子邮件 ID 来确定最终用户对索引中文档的访问权限。当您将 Amazon Kendra 索引连接到时 Amazon Q Business，会将用户的识别电子邮件ID中 Amazon Q Business 继到Amazon Kendra，以便为最终用户启用文档筛选。如果连接到您的 Amazon Kendra 索引的数据源不使用基于电子邮件ID的文档筛选，或者电子邮件ID不存在，则只能从公共文档 Amazon Q Business 生成响应。

## Amazon Kendra 开发人员版索引
<a name="kendra-developer-index"></a>

Amazon Kendra 开发人员版索引还提供语义搜索功能，供您测试使用案例。但是，我们不建议对生产使用案例使用此功能。

**Topics**
+ [支持的功能](#kendra-dev-index-features)
+ [限制](#dev-index-limitations)

### 支持的功能
<a name="kendra-dev-index-features"></a>

如果您在 RAG 使用案例中使用[检索](https://docs.aws.amazon.com/kendra/latest/APIReference/API_Retrieve.html) API 操作，那么 Amazon Kendra 开发人员版索引支持以下功能：使用[高级查询语法](https://docs.aws.amazon.com/kendra/latest/dg/searching-example.html#searching-index-query-syntax)进行查询、对查询使用[建议的拼写更正](https://docs.aws.amazon.com/kendra/latest/dg/query-spell-check.html)、[分面](https://docs.aws.amazon.com/kendra/latest/dg/filtering.html#search-facets)、自动完成搜索查询的[查询建议](https://docs.aws.amazon.com/kendra/latest/dg/query-suggestions.html)以及[增量学习](https://docs.aws.amazon.com/kendra/latest/dg/submitting-feedback.html)。

如果您在搜索使用案例中使用[查询](https://docs.aws.amazon.com/kendra/latest/APIReference/API_Query.html) API 操作，则 Amazon Kendra 开发人员版索引支持所有功能。

### 限制
<a name="dev-index-limitations"></a>

以下内容概述了 Amazon Kendra 开发人员版索引的已知限制：
+ 如果您将 Amazon Kendra 开发者版索引与一起使用 Amazon Q Business，请注意以下有关控制最终用户访问文档的注意事项：

  Amazon Q Business 使用用户电子邮件 ID 来确定最终用户对索引中文档的访问权限。当您将 Amazon Kendra 索引连接到时 Amazon Q Business，会将用户的识别电子邮件ID中 Amazon Q Business 继到Amazon Kendra，以便为最终用户启用文档筛选。如果连接到您的 Amazon Kendra 索引的数据源不使用基于电子邮件ID的文档筛选，或者电子邮件ID不存在，则只能从公共文档 Amazon Q Business 生成响应。

# 在 Amazon Kendra 中向索引中添加文档
<a name="hiw-index-adding-docs"></a>

向索引中添加文档的方式取决于您存储文档的方式。
+ 如果您将文档存储在某种存储库中，例如存储 Amazon S3 桶或 Microsoft SharePoint 站点，则使用[数据源连接器](https://docs.aws.amazon.com/kendra/latest/dg/data-source.html)将存储库中的文档编入索引。
+ 如果您不将文档存储在存储库中，则可以使用 [BatchPutDocument](https://docs.aws.amazon.com/kendra/latest/APIReference/API_BatchPutDocument.html)API 操作直接为文档编制索引。
+ 对于必须存储在 Amazon Kendra (Amazon S3) 存储桶中的常见问题和答案，您可以从存储桶上传它们。

您可以使用 Amazon Kendra 控制台 AWS CLI、或 AWS SDK 创建索引。有关可以编制索引的文档类型的信息，请参阅[文档类型](https://docs.aws.amazon.com/kendra/latest/dg/index-document-types.html)。

# 使用 Amazon Kendra 保留或常用文档字段
<a name="index-reserved-fields-hiw"></a>

[UpdateIndex](https://docs.aws.amazon.com/kendra/latest/APIReference/API_UpdateIndex.html)通过 API 操作，您可以创建保留字段或常用字段。为此`DocumentMetadataConfigurationUpdates`，您可以使用并指定要映射到等效文档名称的 Amazon Kendra 保留索引字段 attribute/field 名称。您还可以创建自定义字段。

如果您使用数据源连接器，则大多数连接器都包含将数据源文档字段映射到 Amazon Kendra 索引字段的字段映射。如果您使用控制台，则要更新字段，方法是选择数据来源，选择编辑操作，然后在“字段映射”部分旁边继续配置数据来源。

您可以将 `Search` 对象配置为将字段设置为可显示、可分面、可搜索和可排序。您可以将 `Relevance` 对象配置为设置字段的排名顺序、提升持续时间或时间段，以应用于映射到特定字段值的提升、新鲜度、重要性值和重要性值。

如果您使用控制台，则可以通过在导航菜单中选择分面选项来配置字段的搜索设置。要设置相关性调试，请在导航菜单中选择搜索索引的选项，输入查询，然后使用侧面板选项调整搜索相关性。创建字段后无法更改字段类型。

Amazon Kendra 有以下可供您使用的保留或常用文档字段：
+ `_authors` – 负责文档内容的一位或多位作者的名单。
+ `_category` – 将文档置于特定组中的类别。
+ `_created_at` – 以 ISO 8601 格式创建文档的日期和时间。例如，2012-03-25T12:30:10\$101:00 是中部欧洲时间 2012 年 3 月 25 日中午 12:30（10 秒）的 ISO 8601 日期-时间格式。
+ `_data_source_id` – 包含文档数据来源的标识符。
+ `_document_body` – 文档的内容。
+ `_document_id` – 文档的唯一标识符。
+ `_document_title` – 文档标题。
+ `_excerpt_page_number` – PDF 文件中显示文档摘录的页码。如果您的索引是在 2020 年 9 月 8 日之前创建的，则必须重新编制文档索引才能使用此属性。
+ `_faq_id` - 如果这是问答类型文档（FAQ），则为常见问题解答的唯一标识符。
+ `_file_type` - 文档的文件类型，例如 pdf 或 doc。
+ `_last_updated_at` – 上次更新端点的日期和时间，采用 ISO 8601 格式。例如，2012-03-25T12:30:10\$101:00 是中部欧洲时间 2012 年 3 月 25 日中午 12:30（10 秒）的 ISO 8601 日期-时间格式。
+ `_source_uri` – 文档的 URI，例如，公司网站上的文档的 URI。
+ `_version` – 文档特定版本的标识符。
+ `_view_count` – 查看文档的次数。
+ `_language_code`（字符串）– 适用于文档的语言的代码。如果您未指定语言，默认为英语。有关支持的语言（包括其代码）的更多信息，请参阅[添加非英语语言文档](https://docs.aws.amazon.com/kendra/latest/dg/in-adding-languages.html)。

您可以将 `DocumentMetadataConfigurationUpdates` 与 `UpdateIndex` API 操作配合使用来创建自定义字段，就像创建保留字段或常用字段时一样。您必须为自定义字段设置相应的数据类型。

如果您使用控制台，则要更新字段，方法是选择数据来源，选择编辑操作，然后在“字段映射”部分旁边继续配置数据来源。某些数据来源不支持添加新字段或自定义字段。创建字段后无法更改字段类型。

以下是您可以为自定义字段设置的类型：
+ 日期
+ 数字
+ 字符串
+ 字符串列表

如果您使用 [BatchPutDocument](https://docs.aws.amazon.com/kendra/latest/APIReference/API_BatchPutDocument.html)API 操作将文档添加到索引，则会`Attributes`列出您的文档，然后使用该`DocumentAttribute`对象创建字段。 fields/attributes 

对于从 Amazon S3 数据源编制索引的文档，您可以使用包含字段信息的 [JSON 元数据文件](https://docs.aws.amazon.com/kendra/latest/dg/s3-metadata.html)创建字段。

如果您使用支持的数据库作为数据来源，则可以使用[字段映射选项](https://docs.aws.amazon.com/kendra/latest/dg/data-source-database.html#data-source-procedure-database)配置字段。

# 从 Amazon Kendra 中的索引中检索响应
<a name="index-searching"></a>

创建索引后，您可以开始搜索文档。

要搜索 Amazon Kendra 索引，您可以使用[检索](https://docs.aws.amazon.com/kendra/latest/APIReference/API_Retrieve.html) API 操作或[查询](https://docs.aws.amazon.com/kendra/latest/APIReference/API_Query.html) API 操作。

检索 API 操作非常适合检索增强生成（RAG）使用案例。对于给定的查询，它会返回一个包含最多 200 个令牌的语义相关段落的排名列表。您可以将它们发送到大型语言模型（LLM），以使用 RAG 生成答案。有关更多信息，请参阅 [Searching an index](https://docs.aws.amazon.com/kendra/latest/dg/searching.html)。

查询 API 操作最适合于文档搜索使用案例。对于给定的查询，它会返回一个排名文档列表，其中包含与查询相关的 100 个单词的摘录。这对于传统的文档搜索使用案例（用户可以在排名文档列表中浏览）非常有用。

要了解每种索引类型的检索 API 和查询 API 操作支持哪些功能，请参阅[索引类型](https://docs.aws.amazon.com/kendra/latest/dg/hiw-index-types.html)。

# 文档
<a name="hiw-documents"></a>

本节说明了如何 Amazon Kendra 索引它所支持的多种文档格式以及文档的不同 fields/attributes 之处。

**Topics**
+ [文档类型或格式](#index-document-types)
+ [文档属性或字段](#hiw-document-attributes)

## 文档类型或格式
<a name="index-document-types"></a>

Amazon Kendra 支持常用的文档类型或格式，例如 PDF、HTML PowerPoint、Word 等。一个索引可以包含多种文档格式。

Amazon Kendra 提取文档内部的内容以使文档可搜索。解析文档的方式是为了优化对提取的文本和文档中任何表格内容（HTML 表格）的搜索。这意味着将文档结构化为用于搜索的字段或属性。文档元数据（例如上次修改日期）可能是有用的搜索字段。

可以将文档组织成行和列。例如，每个文档是一行，每个文档字段/属性（例如标题和正文内容）都是一列。例如，如果您使用数据库作为数据来源，则应将数据结构化或组织成行和列。

您可以通过以下方式将文档添加到索引中：
+ [BatchPutDocument](https://docs.aws.amazon.com/kendra/latest/dg/in-adding-documents.html) API
+ [数据来源连接器](https://docs.aws.amazon.com/kendra/latest/dg/data-sources.html)

如果要添加常见问题解答文件，可以使用 [CreateFaq](https://docs.aws.amazon.com/kendra/latest/dg/in-creating-faq.html)API 添加存储在存储 Amazon S3 桶中的文件。您可以在基本 CSV 格式、标题 fields/attributes 中包含自定义的 CSV 格式和包含自定义字段的 JSON 格式之间进行选择。默认文件格式为 CSV。

以下内容提供了有关每种支持的文档格式以及在为文档编制索引时， Amazon Kendra 如何处理每种格式的信息。


| 文档格式 | 视为 | 如何处理文档 | 原始结构 | 
| --- | --- | --- | --- | 
| 可移植文档格式（PDF） | HTML | 转换为 HTML，然后提取内容。 | 非结构化 | 
| HyperText 标记语言 (HTML) | HTML | HTML 标签会被过滤掉以提取内容。内容必须介于主 HTML 起始标签和结束标签（<HTML>content</HTML>）之间。 | 半结构化 | 
| 可扩展标记语言 (XML) | XML | XML 标签会被过滤掉以提取内容。 | 半结构化 | 
| 可扩展样式表语言转换（XSLT） | XSLT | 标签会被过滤掉以提取内容。 | 半结构化 | 
| MarkDown （医学博士） | 纯文本 | 提取内容时包含 MarkDown 语法。 | 半结构化 | 
| 逗号分隔值（CSV） | CSV | 从每个单元格中提取的内容，将单个文件视为单个文档结果。 | 结构化用于常见问题解答文件，否则为半结构化 | 
| Microsoft Excel（XLS 和 XLSX） | XLS 和 XLSX | 从每个单元格中提取的内容，将单个文件视为单个文档结果。 | 半结构化 | 
| JavaScript 对象表示法 (JSON) | 纯文本 | 内容是使用包含的 JSON 语法提取的。 | 半结构化 | 
| 富文本格式（RTF） | RTF | RTF 语法会被过滤掉以提取内容。 | 半结构化 | 
| 微软 PowerPoint (PPT) | PPT、PPTX | 仅从 PowerPoint 幻灯片中提取文本内容进行搜索。不会提取图像和其他内容。 | 非结构化 | 
| Microsoft Word | DOC、DOCX | 仅从 Word 页面中提取文本内容进行搜索。不会提取图像和其他内容。 | 非结构化 | 
| 纯文本（TXT） | TXT | 提取文本文档中的所有文本。 | 非结构化 | 

## 文档属性或字段
<a name="hiw-document-attributes"></a>

文档具有与之关联的属性或字段。文档的字段是文档的属性或文档结构中包含的内容。例如，您的每个文档都可能包含标题、正文和作者。您也可以为特定文档添加自定义字段。例如，如果您的索引搜索税务文件，则可以为税务文件类型指定自定义字段，例如 W-2、1099 等。

在查询中使用文档字段之前，必须将其映射到索引字段。例如，标题字段可以映射到字段 `_document_title`。有关更多信息，请参阅[映射字段](https://docs.aws.amazon.com/kendra/latest/dg/field-mapping.html)。要添加新字段，必须创建要将该字段映射到的索引字段。您可以使用控制台或 [UpdateIndex](https://docs.aws.amazon.com/kendra/latest/APIReference/API_UpdateIndex.html)API 创建索引字段。

您可以使用文档字段来筛选回复并生成分面搜索结果。例如，您可以筛选回复以仅返回文档的特定版本，也可以筛选搜索结果以仅返回与搜索词匹配的 1099 种税务文件。有关更多信息，请参阅[筛选和分面搜索](https://docs.aws.amazon.com/kendra/latest/dg/filtering.html)。

您也可以使用文档字段来手动调整查询响应。例如，在确定要在回复中返回哪些文档时，您可以选择提高标题字段的重要性以增加 Amazon Kendra 分配给该字段的权重。有关更多信息，请参阅[调整搜索相关性](https://docs.aws.amazon.com/kendra/latest/dg/tuning.html)。

如果要将文档直接添加到索引，则需要在 [BatchPutDocument](https://docs.aws.amazon.com/kendra/latest/APIReference/API_BatchPutDocument.html)API 的[文档](https://docs.aws.amazon.com/kendra/latest/APIReference/API_Document.html)输入参数中指定字段。您可以在[DocumentAttribute](https://docs.aws.amazon.com/kendra/latest/APIReference/API_DocumentAttribute.html)对象数组中指定自定义字段值。如果您使用的是数据来源，则用于添加文档字段的方法取决于数据来源。有关更多信息，请参阅[映射数据来源字段](https://docs.aws.amazon.com/kendra/latest/dg/field-mapping.html)。

### 使用 Amazon Kendra 保留或常用文档字段
<a name="index-reserved-fields"></a>

借助 [UpdateIndex API](https://docs.aws.amazon.com/kendra/latest/APIReference/API_UpdateIndex.html)，您可以使用`DocumentMetadataConfigurationUpdates`并指定要映射到等效文档名称的 Amazon Kendra 保留索引字段名称来创建保留字段或常用 attribute/field 字段。您还可以创建自定义字段。如果您使用数据源连接器，则大多数连接器都包含将数据源文档字段映射到 Amazon Kendra 索引字段的字段映射。如果您使用控制台，则要更新字段，方法是选择数据来源，选择编辑操作，然后在“字段映射”部分旁边继续配置数据来源。

您可以将 `Search` 对象配置为将字段设置为可显示、可分面、可搜索和可排序。您可以将 `Relevance` 对象配置为设置字段的排名顺序、提升持续时间或时间段，以应用于映射到特定字段值的提升、新鲜度、重要性值和重要性值。如果您使用控制台，则可以通过在导航菜单中选择 facet 选项来设置字段的搜索设置。要设置相关性调整，请在导航菜单中选择搜索索引的选项，输入查询，然后使用侧面板选项调整搜索相关性。创建字段后无法更改字段类型。

Amazon Kendra 有以下可供您使用的保留或常用文档字段：
+ `_authors` - 负责文档内容的一位或多位作者名单。
+ `_category` - 将文档置于特定组中的类别。
+ `_created_at` - 以 ISO 8601 格式创建文档的日期和时间。例如，2012-03-25T12:30:10\$101:00 是中部欧洲时间 2012 年 3 月 25 日中午 12:30（10 秒）的 ISO 8601 日期-时间格式。
+ `_data_source_id` - 包含文档数据来源的标识符。
+ `_document_body` - 文档的内容。
+ `_document_id` - 文档的唯一标识符。
+ `_document_title` - 文档标题。
+ `_excerpt_page_number` - PDF 文件中显示文档摘录的页码。如果您的索引是在 2020 年 9 月 8 日之前创建的，则必须重新编制文档索引才能使用此属性。
+ `_faq_id` - 如果这是问答类型文档（FAQ），则为常见问题解答的唯一标识符。
+ `_file_type` - 文档的文件类型，例如 pdf 或 doc。
+ `_last_updated_at` - 上次更新端点的日期和时间，采用 ISO 8601 格式。例如，2012-03-25T12:30:10\$101:00 是中部欧洲时间 2012 年 3 月 25 日中午 12:30（10 秒）的 ISO 8601 日期-时间格式。
+ `_source_uri` - 文档可用的 URI。例如，公司网站上的文档的 URI。
+ `_version` - 文档特定版本的标识符。
+ `_view_count` - 查看文档的次数。
+ `_language_code`（字符串）– 适用于文档的语言的代码。如果您未指定语言，默认为英语。有关支持的语言（包括其代码）的更多信息，请参阅[添加非英语语言文档](https://docs.aws.amazon.com/kendra/latest/dg/in-adding-languages.html)。

对于自定义字段，您可以将 `DocumentMetadataConfigurationUpdates` 与 `UpdateIndex` API 配合使用来创建这些字段，就像创建保留字段或公用字段时一样。您必须为自定义字段设置相应的数据类型。如果您使用控制台，则要更新字段，方法是选择数据来源，选择编辑操作，然后在“字段映射”部分旁边继续配置数据来源。某些数据来源不支持添加新字段或自定义字段。创建字段后无法更改字段类型。

以下是您可以为自定义字段设置的类型：
+ 日期
+ 数字
+ 字符串
+ 字符串列表

如果您使用 [BatchPutDocument](https://docs.aws.amazon.com/kendra/latest/APIReference/API_BatchPutDocument.html)API 将文档添加到索引中，则会`Attributes` fields/attributes 列出您的文档，然后使用该`DocumentAttribute`对象创建字段。

对于从 Amazon S3 数据源编制索引的文档，您可以使用包含字段信息的 [JSON 元数据文件](https://docs.aws.amazon.com/kendra/latest/dg/s3-metadata.html)创建字段。

如果您使用支持的数据库作为数据来源，则可以使用[字段映射选项](https://docs.aws.amazon.com/kendra/latest/dg/data-source-database.html#data-source-procedure-database)配置字段。

# 数据来源
<a name="hiw-data-source"></a>

数据源是 Amazon Kendra 连接到您的文档或内容并为其编制索引的数据存储库或位置。例如，您可以配置为连接 Amazon Kendra 到 Microsoft SharePoint ，以便对存储在此源中的文档进行抓取和索引。您还可以通过提供 for to crawl URLs Amazon Kendra 来索引网页。您可以自动将数据源与 Amazon Kendra 索引同步，这样数据源中添加、更新或删除的文档也可以在索引中添加、更新或删除。

支持的数据来源包括：
+ [Adobe Experience Manager](https://docs.aws.amazon.com/kendra/latest/dg/data-source-aem.html)
+ [Alfresco](https://docs.aws.amazon.com/kendra/latest/dg/data-source-alfresco.html)
+ [Aurora （MySQL）](https://docs.aws.amazon.com/kendra/latest/dg/data-source-aurora-mysql.html)
+ [Aurora （PostgreSQL）](https://docs.aws.amazon.com/kendra/latest/dg/data-source-aurora-postgresql.html)
+ [Amazon FSx （视窗）](https://docs.aws.amazon.com/kendra/latest/dg/data-source-fsx.html)
+ [Amazon FSx （NetApp ONTAP）](https://docs.aws.amazon.com/kendra/latest/dg/data-source-fsx-ontap.html) 
+  [数据库数据来源](https://docs.aws.amazon.com/kendra/latest/dg/data-source-database.html)
+ [Amazon RDS （Microsoft SQL Server）](https://docs.aws.amazon.com/kendra/latest/dg/data-source-rds-ms-sql-server.html)
+ [Amazon RDS (MySQL)](https://docs.aws.amazon.com/kendra/latest/dg/data-source-rds-mysql.html)
+ [Amazon RDS （甲骨文）](https://docs.aws.amazon.com/kendra/latest/dg/data-source-rds-oracle.html)
+ [Amazon RDS （PostgreSQL）](https://docs.aws.amazon.com/kendra/latest/dg/data-source-rds-postgresql.html)
+ [Amazon S3 水桶](https://docs.aws.amazon.com/kendra/latest/dg/data-source-s3.html)
+ [Amazon Kendra 网络爬虫](https://docs.aws.amazon.com/kendra/latest/dg/data-source-web-crawler.html)
+ [Box](https://docs.aws.amazon.com/kendra/latest/dg/data-source-box.html)
+ [Confluence](https://docs.aws.amazon.com/kendra/latest/dg/data-source-confluence.html)
+ [自定义数据来源](https://docs.aws.amazon.com/kendra/latest/dg/data-source-custom.html)
+ [Dropbox](https://docs.aws.amazon.com/kendra/latest/dg/data-source-dropbox.html)
+ [Drupal](https://docs.aws.amazon.com/kendra/latest/dg/data-source-drupal.html)
+ [GitHub](https://docs.aws.amazon.com/kendra/latest/dg/data-source-github.html)
+ [Gmail](https://docs.aws.amazon.com/kendra/latest/dg/data-source-gmail.html)
+ [Google Workspace Drives](https://docs.aws.amazon.com/kendra/latest/dg/data-source-google-drive.html)
+ [IBM DB2](https://docs.aws.amazon.com/kendra/latest/dg/data-source-ibm-db2.html)
+ [Jira](https://docs.aws.amazon.com/kendra/latest/dg/data-source-jira.html)
+ [Microsoft Exchange](https://docs.aws.amazon.com/kendra/latest/dg/data-source-exchange.html)
+ [微软 OneDrive](https://docs.aws.amazon.com/kendra/latest/dg/data-source-onedrive.html)
+ [微软 SharePoint](https://docs.aws.amazon.com/kendra/latest/dg/data-source-sharepoint.html)
+ [Microsoft Teams](https://docs.aws.amazon.com/kendra/latest/dg/data-source-teams.html)
+ [Microsoft SQL Server](https://docs.aws.amazon.com/kendra/latest/dg/data-source-ms-sql-server.html)
+ [Microsoft Yammer](https://docs.aws.amazon.com/kendra/latest/dg/data-source-yammer.html)
+ [MySQL](https://docs.aws.amazon.com/kendra/latest/dg/data-source-mysql.html)
+ [Oracle Database](https://docs.aws.amazon.com/kendra/latest/dg/data-source-oracle-database.html)
+ [PostgreSQL](https://docs.aws.amazon.com/kendra/latest/dg/data-source-postgresql.html)
+ [Quip](https://docs.aws.amazon.com/kendra/latest/dg/data-source-quip.html)
+ [Salesforce](https://docs.aws.amazon.com/kendra/latest/dg/data-source-salesforce.html)
+ [ServiceNow](https://docs.aws.amazon.com/kendra/latest/dg/data-source-servicenow.html)
+ [Slack](https://docs.aws.amazon.com/kendra/latest/dg/data-source-slack.html)
+ [Zendesk](https://docs.aws.amazon.com/kendra/latest/dg/data-source-zendesk.html)

有关支持的文档类型或格式的列表， Amazon Kendra 请参阅[文档类型](https://docs.aws.amazon.com/kendra/latest/dg/index-document-types.html)。在创建数据来源连接器之前，必须先创建索引，以便为数据来源中的文档编制索引。

**注意**  
要创建文档索引，无需使用数据来源。通过批量上传将文档直接添加到索引中。有关更多信息，请参阅[将文档直接添加到索引中](https://docs.aws.amazon.com/kendra/latest/dg/in-adding-documents.html)。

 有关使用 Amazon Kendra 控制台、 AWS CLI 或的演练 SDKs，请参阅[入门](https://docs.aws.amazon.com/kendra/latest/dg/getting-started.html)。

# 查询
<a name="hiw-query"></a>

要获得答案，用户需要查询索引。用户可以在查询中使用自然语言。该响应包含信息，例如标题、文本摘录以及提供最佳答案的文档在索引中的位置。

Amazon Kendra 使用您提供的有关文档的所有信息，而不仅仅是文档的内容，来确定文档是否与查询相关。例如，如果您的索引包含有关上次更新文档的时间的信息，则可以告诉您 Amazon Kendra 为最近更新的文档分配更高的相关性。

查询还可以包含如何筛选响应的标准，以便仅 Amazon Kendra 返回满足筛选条件的文档。例如，如果您创建了一个名为 *department* 的索引字段，则可以筛选响应，以便仅返回部门字段设置为 *legal* 的文档。有关更多信息，请参阅[筛选搜索](https://docs.aws.amazon.com/kendra/latest/dg/filtering.html)。

您可以通过调整索引中各个字段的相关性来影响查询结果。调整会改变字段在结果中的重要性。例如，如果您使用*新*类别提高文档的重要性，则该类别的文档更有可能包含在回复中。有关更多信息，请参阅[调整搜索相关性](https://docs.aws.amazon.com/kendra/latest/dg/tuning.html)。

有关使用查询的更多信息，请参阅[搜索索引](https://docs.aws.amazon.com/kendra/latest/dg/searching.html)。

# 标签
<a name="tagging"></a>

通过分配标签或标签 FAQs 来管理您的索引、数据源。您可以使用标签以各种方式对 Amazon Kendra 资源进行分类。例如，按用途、所有者或应用程序进行分类，或按任意组合进行分类。每个标签都由*键*和*值*组成，这两个参数都由您定义。

标签帮助您：
+ 识别和整理您的 AWS 资源。许多 AWS 服务都支持标记，因此您可以为不同服务中的资源分配相同的标签，以表明这些资源是相关的。例如，您可以使用相同的标签标记索引和使用该索引的 Amazon Lex 机器人。
+ 分配成本。您可以在 AWS 账单与成本管理 控制面板上激活标签。 AWS 使用标签对您的成本进行分类，并向您提供每月成本分配报告。有关更多信息，请参阅《*关于 AWS 账单和成本管理》中的 “成本分配和*[标记](https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/cost-alloc-tags.html)”。
+ 控制对 资源的访问。您可以在 AWS Identity and Access Management （IAM）策略中使用标签来控制对 Amazon Kendra 资源的访问。您可以将这些策略附加到 IAM 角色或用户，以激活基于标签的访问控制。有关更多信息，请参阅[基于标签的身份验证](https://docs.aws.amazon.com/kendra/latest/dg/security_iam_service-with-iam.html#security_iam_service-with-iam-tags)。

您可以使用 AWS 管理控制台、 AWS Command Line Interface (AWS CLI) 或 Amazon Kendra API 创建和管理标签。

## 标注资源
<a name="tagging-resources"></a>

如果您使用的是 Amazon Kendra 控制台，则可以在创建资源时对其进行标记，也可以在以后添加资源。您还可以使用控制台来更新或删除标签。

如果您使用的是 AWS Command Line Interface (AWS CLI) 或 Amazon Kendra API，请使用以下操作来管理资源的标签：
+ [CreateDataSource](https://docs.aws.amazon.com/kendra/latest/APIReference/API_CreateDataSource.html)— 在创建数据源时应用标签。
+ [CreateFaq](https://docs.aws.amazon.com/kendra/latest/APIReference/API_CreateFaq.html)—创建常见问题解答时应用标签。
+ [CreateIndex](https://docs.aws.amazon.com/kendra/latest/APIReference/API_CreateIndex.html)—创建索引时应用标签。
+ [ListTagsForResource](https://docs.aws.amazon.com/kendra/latest/APIReference/API_ListTagsForResource.html)— 查看与资源关联的标签。
+ [TagResource](https://docs.aws.amazon.com/kendra/latest/APIReference/API_TagResource.html)— 为资源添加和修改标签。
+ [UntagResource](https://docs.aws.amazon.com/kendra/latest/APIReference/API_UntagResource.html)— 从资源中移除标签。

## 标签限制
<a name="tag-restrictions"></a>

以下限制适用于 Amazon Kendra 资源上的标签：
+ 最大标签数量 - 50
+ 最大键长度 – 128 个字符
+ 最大值长度 – 256 个字符
+ 键和值的有效字符 - a-z、A-Z、空格和以下字符：\$1 . : / = \$1 - 和 @
+ 键和值区分大小写
+ 请不要使用 `aws:` 作为键的前缀；它保留为供 AWS 使用