本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
您可以使用中繼資料檔案,將中繼資料、文件的其他資訊新增至 Amazon S3 儲存貯體中的文件。每個中繼資料檔案都與索引文件相關聯。
您的中繼資料檔案必須與索引檔案存放在相同的儲存貯體中。您可以在建立 Amazon S3 資料來源時,使用 主控台或 DocumentsMetadataConfiguration
參數S3Prefix
欄位,為中繼資料檔案指定儲存貯體中的位置。如果您未指定 Amazon S3 字首,您的中繼資料檔案必須存放在與索引文件相同的位置。
如果您為中繼資料檔案指定 Amazon S3 字首,則它們位於與索引文件平行的目錄結構中。僅 Amazon Kendra 尋找中繼資料的指定目錄中。如果未讀取中繼資料,請檢查目錄位置是否符合中繼資料的位置。
下列範例顯示索引文件位置如何對應至中繼資料檔案位置。請注意,文件的 Amazon S3 金鑰會附加到中繼資料的 Amazon S3 字首,然後加上 的尾碼.metadata.json
,以形成中繼資料檔案的 Amazon S3 路徑。包含中繼資料 Amazon S3 前綴和.metadata.json
後綴的合併 Amazon S3 索引鍵總計不得超過 1024 個字元。建議您將 Amazon S3 金鑰保留在 1000 個字元以下,以便在將金鑰與字首和尾結合時考慮額外的字元。
Bucket name:
s3://bucketName
Document path:
documents
Metadata path:
none
File mapping
s3://bucketName/documents/file.txt ->
s3://bucketName/documents/file.txt.metadata.json
Bucket name:
s3://bucketName
Document path:
documents/legal
Metadata path:
metadata
File mapping
s3://bucketName/documents/legal/file.txt ->
s3://bucketName/metadata/documents/legal/file.txt.metadata.json
您的文件中繼資料是在 JSON 檔案中定義。檔案必須是沒有 BOM 標記的 UTF-8 文字檔案。JSON 檔案的檔案名稱必須為 <document>.<extension>.metadata.json
。在此範例中,「文件」是中繼資料適用的文件名稱,而「延伸」是文件的副檔名。文件 ID 在 中必須是唯一的<document>.<extension>.metadata.json
。
JSON 檔案的內容遵循此範本。所有屬性/欄位都是選用的,因此不需要包含所有屬性。您必須為每個要包含的屬性提供一個值;該值不能為空。如果您未指定 _source_uri
,則搜尋結果 Amazon Kendra 中傳回的連結會指向包含文件的儲存 Amazon S3 貯體。 DocumentId
會對應至 欄位,s3_document_id
且 是 S3 中文件的絕對路徑。
{
"DocumentId": "S3 document ID, the S3 path to doc
",
"Attributes": {
"_category": "document category
",
"_created_at": "ISO 8601 encoded string
",
"_last_updated_at": "ISO 8601 encoded string
",
"_source_uri": "document URI
",
"_version": "file version
",
"_view_count": number of times document has been viewed
,
"custom attribute key": "custom attribute value",
additional custom attributes
},
"AccessControlList": [
{
"Name": "user name
",
"Type": "GROUP
| USER
",
"Access": "ALLOW
| DENY
"
}
],
"Title": "document title
",
"ContentType": "For example HTML
| PDF
. For supported content types, see Types of documents."
}
_created_at
和 _last_updated_at
中繼資料欄位是 ISO 8601 編碼的日期。例如,2012-03-25T12 月 25 日下午 12:30 (加上 10 秒),歐洲中部時區的 2012 年 3 月 35 日 ISO 8601 日期時間格式為 2012 年 3 月 30 日 12:30。
您可以將有關用來篩選查詢或分組查詢回應之文件的其他資訊新增至 Attributes
欄位。如需詳細資訊,請參閱建立自訂文件欄位。
您可以使用 AccessControlList
欄位來篩選查詢的回應。如此一來,只有特定使用者和群組可以存取文件。如需詳細資訊,請參閱依使用者內容篩選。