Skip to content

batch_put_document

batch_put_document(
    index_id: IndexId,
    documents: DocumentList,
    *,
    config_overrides: Optional[kendraClientConfig] = None,
    role_arn: Optional[RoleArn] = None,
    custom_document_enrichment_configuration: Optional[
        CustomDocumentEnrichmentConfiguration
    ] = None,
) -> BatchPutDocumentResponse

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.

Parameters:

  • index_id (IndexId) –

    The identifier of the index to add the documents to. You need to create the index first using the CreateIndex API.

  • role_arn (Optional[RoleArn], default: None ) –

    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.

  • documents (DocumentList) –

    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

    For more information, see Quotas.

  • custom_document_enrichment_configuration (Optional[CustomDocumentEnrichmentConfiguration], default: None ) –

    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.

Raises:

  • AccessDeniedException –

    You don't have sufficient access to perform this action. Please ensure you have the required permission policies and user accounts and try again.

  • ConflictException –

    A conflict occurred with the request. Please fix any inconsistences with your resources and try again.

  • InternalServerException –

    An issue occurred with the internal server used for your Amazon Kendra service. Please wait a few minutes and try again, or contact Support for help.

  • ResourceNotFoundException –

    The resource you want to use doesn’t exist. Please check you have provided the correct resource and try again.

  • ServiceQuotaExceededException –

    You have exceeded the set limits for your Amazon Kendra service. Please see Quotas for more information, or contact Support to inquire about an increase of limits.

  • ThrottlingException –

    The request was denied due to request throttling. Please reduce the number of requests and try again.

  • ValidationException –

    The input fails to satisfy the constraints set by the Amazon Kendra service. Please provide the correct input and try again.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_kendra/_services/kendra.py
def batch_put_document(
    self,
    index_id: "capo_kendra.types.index_id.IndexId",
    documents: "capo_kendra.types.document_list.DocumentList",
    *,
    config_overrides: Optional[kendraClientConfig] = None,
    role_arn: Optional["capo_kendra.types.role_arn.RoleArn"] = None,
    custom_document_enrichment_configuration: Optional[
        "capo_kendra.types.custom_document_enrichment_configuration.CustomDocumentEnrichmentConfiguration"
    ] = None,
) -> "capo_kendra.types.batch_put_document_response.BatchPutDocumentResponse":
    """<p>Adds one or more documents to an index.</p> <p>The <code>BatchPutDocument</code> 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.</p> <p>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 <code>BatchGetDocumentStatus</code> API to monitor the progress of indexing your documents.</p> <p>For an example of ingesting inline documents using Python and Java SDKs, see <a href="https://docs.aws.amazon.com/kendra/latest/dg/in-adding-binary-doc.html">Adding files directly to an index</a>.</p>

    Args:
        index_id: <p>The identifier of the index to add the documents to. You need to create the index first using the <code>CreateIndex</code> API.</p>
        role_arn: <p>The Amazon Resource Name (ARN) of an IAM role with permission to access your S3 bucket. For more information, see <a href="https://docs.aws.amazon.com/kendra/latest/dg/iam-roles.html">IAM access roles for Amazon Kendra</a>.</p>
        documents: <p>One or more documents to add to the index.</p> <p>Documents have the following file size limits.</p> <ul> <li> <p>50 MB total size for any file</p> </li> <li> <p>5 MB extracted text for any file</p> </li> </ul> <p>For more information, see <a href="https://docs.aws.amazon.com/kendra/latest/dg/quotas.html">Quotas</a>.</p>
        custom_document_enrichment_configuration: <p>Configuration information for altering your document metadata and content during the document ingestion process when you use the <code>BatchPutDocument</code> API.</p> <p>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 <a href="https://docs.aws.amazon.com/kendra/latest/dg/custom-document-enrichment.html">Customizing document metadata during the ingestion process</a>.</p>

    Raises:
        capo_kendra.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access to perform this action. Please ensure you have the required permission policies and user accounts and try again.</p>
        capo_kendra.errors.conflict_exception.ConflictException: <p>A conflict occurred with the request. Please fix any inconsistences with your resources and try again.</p>
        capo_kendra.errors.internal_server_exception.InternalServerException: <p>An issue occurred with the internal server used for your Amazon Kendra service. Please wait a few minutes and try again, or contact <a href="http://aws.amazon.com/contact-us/">Support</a> for help.</p>
        capo_kendra.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource you want to use doesn’t exist. Please check you have provided the correct resource and try again.</p>
        capo_kendra.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>You have exceeded the set limits for your Amazon Kendra service. Please see <a href="https://docs.aws.amazon.com/kendra/latest/dg/quotas.html">Quotas</a> for more information, or contact <a href="http://aws.amazon.com/contact-us/">Support</a> to inquire about an increase of limits.</p>
        capo_kendra.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling. Please reduce the number of requests and try again.</p>
        capo_kendra.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints set by the Amazon Kendra service. Please provide the correct input and try again.</p>
        capo_kendra.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_kendra.types.batch_put_document_request.BatchPutDocumentRequest]",
    ) -> OperationResponse[
        "capo_kendra.types.batch_put_document_response.BatchPutDocumentResponse"
    ]:
        import capo_kendra._operations.aws_kendra_frontend_service.batch_put_document

        output, http_response = (
            capo_kendra._operations.aws_kendra_frontend_service.batch_put_document.batch_put_document(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("BatchPutDocument")
    )
    input_: capo_kendra.types.batch_put_document_request.BatchPutDocumentRequest = {
        "index_id": index_id,
        "documents": documents,
    }
    if role_arn is not None:
        input_["role_arn"] = role_arn
    if custom_document_enrichment_configuration is not None:
        input_["custom_document_enrichment_configuration"] = (
            custom_document_enrichment_configuration
        )

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output