batchPutDocument method
Adds one or more documents to an index.
The BatchPutDocument API enables you to ingest inline
documents or a set of documents stored in an Amazon S3 bucket. Use this
API to ingest your text and unstructured text into an index, add custom
attributes to the documents, and to attach an access control list to the
documents added to the index.
The documents are indexed asynchronously. You can see the progress of the
batch using Amazon Web Services CloudWatch. Any error messages related to
processing the batch are sent to your Amazon Web Services CloudWatch log.
You can also use the BatchGetDocumentStatus API to monitor
the progress of indexing your documents.
For an example of ingesting inline documents using Python and Java SDKs, see Adding files directly to an index.
May throw AccessDeniedException.
May throw ConflictException.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw ValidationException.
Parameter documents :
One or more documents to add to the index.
Documents have the following file size limits.
- 50 MB total size for any file
- 5 MB extracted text for any file
Parameter indexId :
The identifier of the index to add the documents to. You need to create
the index first using the CreateIndex API.
Parameter customDocumentEnrichmentConfiguration :
Configuration information for altering your document metadata and content
during the document ingestion process when you use the
BatchPutDocument API.
For more information on how to create, modify and delete document metadata, or make other content alterations when you ingest documents into Amazon Kendra, see Customizing document metadata during the ingestion process.
Parameter roleArn :
The Amazon Resource Name (ARN) of an IAM role with permission to access
your S3 bucket. For more information, see IAM
access roles for Amazon Kendra.
Implementation
Future<BatchPutDocumentResponse> batchPutDocument({
required List<Document> documents,
required String indexId,
CustomDocumentEnrichmentConfiguration?
customDocumentEnrichmentConfiguration,
String? roleArn,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AWSKendraFrontendService.BatchPutDocument'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'Documents': documents,
'IndexId': indexId,
if (customDocumentEnrichmentConfiguration != null)
'CustomDocumentEnrichmentConfiguration':
customDocumentEnrichmentConfiguration,
if (roleArn != null) 'RoleArn': roleArn,
},
);
return BatchPutDocumentResponse.fromJson(jsonResponse.body);
}