Skip to content

create_thesaurus async

create_thesaurus(
    index_id: IndexId,
    name: ThesaurusName,
    role_arn: RoleArn,
    source_s3_path: S3Path,
    *,
    config_overrides: Optional[AsynckendraClientConfig] = None,
    description: Optional[Description] = None,
    tags: Optional[TagList] = None,
    client_token: Optional[ClientTokenName] = None,
) -> CreateThesaurusResponse

Creates a thesaurus for an index. The thesaurus contains a list of synonyms in Solr format.

For an example of adding a thesaurus file to an index, see Adding custom synonyms to an index.

Parameters:

  • index_id (IndexId) –

    The identifier of the index for the thesaurus.

  • name (ThesaurusName) –

    A name for the thesaurus.

  • description (Optional[Description], default: None ) –

    A description for the thesaurus.

  • role_arn (RoleArn) –

    The Amazon Resource Name (ARN) of an IAM role with permission to access your S3 bucket that contains the thesaurus file. For more information, see IAM access roles for Amazon Kendra.

  • tags (Optional[TagList], default: None ) –

    A list of key-value pairs that identify or categorize the thesaurus. You can also use tags to help control access to the thesaurus. Tag keys and values can consist of Unicode letters, digits, white space, and any of the following symbols: _ . : / = + - @.

  • source_s3_path (S3Path) –

    The path to the thesaurus file in S3.

  • client_token (Optional[ClientTokenName], default: None ) –

    A token that you provide to identify the request to create a thesaurus. Multiple calls to the CreateThesaurus API with the same client token will create only one thesaurus.

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/async_kendra.py
async def create_thesaurus(
    self,
    index_id: "capo_kendra.types.index_id.IndexId",
    name: "capo_kendra.types.thesaurus_name.ThesaurusName",
    role_arn: "capo_kendra.types.role_arn.RoleArn",
    source_s3_path: "capo_kendra.types.s3_path.S3Path",
    *,
    config_overrides: Optional[AsynckendraClientConfig] = None,
    description: Optional["capo_kendra.types.description.Description"] = None,
    tags: Optional["capo_kendra.types.tag_list.TagList"] = None,
    client_token: Optional[
        "capo_kendra.types.client_token_name.ClientTokenName"
    ] = None,
) -> "capo_kendra.types.create_thesaurus_response.CreateThesaurusResponse":
    """<p>Creates a thesaurus for an index. The thesaurus contains a list of synonyms in Solr format.</p> <p>For an example of adding a thesaurus file to an index, see <a href="https://docs.aws.amazon.com/kendra/latest/dg/index-synonyms-adding-thesaurus-file.html">Adding custom synonyms to an index</a>.</p>

    Args:
        index_id: <p>The identifier of the index for the thesaurus.</p>
        name: <p>A name for the thesaurus.</p>
        description: <p>A description for the thesaurus.</p>
        role_arn: <p>The Amazon Resource Name (ARN) of an IAM role with permission to access your S3 bucket that contains the thesaurus file. 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>
        tags: <p>A list of key-value pairs that identify or categorize the thesaurus. You can also use tags to help control access to the thesaurus. Tag keys and values can consist of Unicode letters, digits, white space, and any of the following symbols: _ . : / = + - @.</p>
        source_s3_path: <p>The path to the thesaurus file in S3.</p>
        client_token: <p>A token that you provide to identify the request to create a thesaurus. Multiple calls to the <code>CreateThesaurus</code> API with the same client token will create only one thesaurus. </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.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_kendra.types.create_thesaurus_request.CreateThesaurusRequest]",
    ) -> AsyncOperationResponse[
        "capo_kendra.types.create_thesaurus_response.CreateThesaurusResponse"
    ]:
        import capo_kendra._operations.aws_kendra_frontend_service.create_thesaurus

        (
            output,
            http_response,
        ) = await capo_kendra._operations.aws_kendra_frontend_service.create_thesaurus.async_create_thesaurus(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateThesaurus")
    )
    input_: capo_kendra.types.create_thesaurus_request.CreateThesaurusRequest = {
        "index_id": index_id,
        "name": name,
        "role_arn": role_arn,
        "source_s3_path": source_s3_path,
    }
    if description is not None:
        input_["description"] = description
    if tags is not None:
        input_["tags"] = tags
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output