Skip to content

create_query_suggestions_block_list

create_query_suggestions_block_list(
    index_id: IndexId,
    name: QuerySuggestionsBlockListName,
    source_s3_path: S3Path,
    role_arn: RoleArn,
    *,
    config_overrides: Optional[kendraClientConfig] = None,
    description: Optional[Description] = None,
    client_token: Optional[ClientTokenName] = None,
    tags: Optional[TagList] = None,
) -> CreateQuerySuggestionsBlockListResponse

Creates a block list to exlcude certain queries from suggestions.

Any query that contains words or phrases specified in the block list is blocked or filtered out from being shown as a suggestion.

You need to provide the file location of your block list text file in your S3 bucket. In your text file, enter each block word or phrase on a separate line.

For information on the current quota limits for block lists, see Quotas for Amazon Kendra.

CreateQuerySuggestionsBlockList is currently not supported in the Amazon Web Services GovCloud (US-West) region.

For an example of creating a block list for query suggestions using the Python SDK, see Query suggestions block list.

Parameters:

  • index_id (IndexId) –

    The identifier of the index you want to create a query suggestions block list for.

  • name (QuerySuggestionsBlockListName) –

    A name for the block list.

    For example, the name 'offensive-words', which includes all offensive words that could appear in user queries and need to be blocked from suggestions.

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

    A description for the block list.

    For example, the description "List of all offensive words that can appear in user queries and need to be blocked from suggestions."

  • source_s3_path (S3Path) –

    The S3 path to your block list text file in your S3 bucket.

    Each block word or phrase should be on a separate line in a text file.

    For information on the current quota limits for block lists, see Quotas for Amazon Kendra.

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

    A token that you provide to identify the request to create a query suggestions block list.

  • role_arn (RoleArn) –

    The Amazon Resource Name (ARN) of an IAM role with permission to access your S3 bucket that contains the block list text 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 block list. Tag keys and values can consist of Unicode letters, digits, white space, and any of the following symbols: _ . : / = + - @.

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 create_query_suggestions_block_list(
    self,
    index_id: "capo_kendra.types.index_id.IndexId",
    name: "capo_kendra.types.query_suggestions_block_list_name.QuerySuggestionsBlockListName",
    source_s3_path: "capo_kendra.types.s3_path.S3Path",
    role_arn: "capo_kendra.types.role_arn.RoleArn",
    *,
    config_overrides: Optional[kendraClientConfig] = None,
    description: Optional["capo_kendra.types.description.Description"] = None,
    client_token: Optional[
        "capo_kendra.types.client_token_name.ClientTokenName"
    ] = None,
    tags: Optional["capo_kendra.types.tag_list.TagList"] = None,
) -> "capo_kendra.types.create_query_suggestions_block_list_response.CreateQuerySuggestionsBlockListResponse":
    """<p>Creates a block list to exlcude certain queries from suggestions.</p> <p>Any query that contains words or phrases specified in the block list is blocked or filtered out from being shown as a suggestion.</p> <p>You need to provide the file location of your block list text file in your S3 bucket. In your text file, enter each block word or phrase on a separate line.</p> <p>For information on the current quota limits for block lists, see <a href="https://docs.aws.amazon.com/kendra/latest/dg/quotas.html">Quotas for Amazon Kendra</a>.</p> <p> <code>CreateQuerySuggestionsBlockList</code> is currently not supported in the Amazon Web Services GovCloud (US-West) region.</p> <p>For an example of creating a block list for query suggestions using the Python SDK, see <a href="https://docs.aws.amazon.com/kendra/latest/dg/query-suggestions.html#query-suggestions-blocklist">Query suggestions block list</a>.</p>

    Args:
        index_id: <p>The identifier of the index you want to create a query suggestions block list for.</p>
        name: <p>A name for the block list.</p> <p>For example, the name 'offensive-words', which includes all offensive words that could appear in user queries and need to be blocked from suggestions.</p>
        description: <p>A description for the block list.</p> <p>For example, the description "List of all offensive words that can appear in user queries and need to be blocked from suggestions."</p>
        source_s3_path: <p>The S3 path to your block list text file in your S3 bucket.</p> <p>Each block word or phrase should be on a separate line in a text file.</p> <p>For information on the current quota limits for block lists, see <a href="https://docs.aws.amazon.com/kendra/latest/dg/quotas.html">Quotas for Amazon Kendra</a>.</p>
        client_token: <p>A token that you provide to identify the request to create a query suggestions block list.</p>
        role_arn: <p>The Amazon Resource Name (ARN) of an IAM role with permission to access your S3 bucket that contains the block list text 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 block list. Tag keys and values can consist of Unicode letters, digits, white space, and any of the following symbols: _ . : / = + - @.</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.create_query_suggestions_block_list_request.CreateQuerySuggestionsBlockListRequest]",
    ) -> OperationResponse[
        "capo_kendra.types.create_query_suggestions_block_list_response.CreateQuerySuggestionsBlockListResponse"
    ]:
        import capo_kendra._operations.aws_kendra_frontend_service.create_query_suggestions_block_list

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

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

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