Skip to content

get_query_suggestions

get_query_suggestions(
    index_id: IndexId,
    query_text: SuggestionQueryText,
    *,
    config_overrides: Optional[kendraClientConfig] = None,
    max_suggestions_count: Optional[Integer] = None,
    suggestion_types: Optional[SuggestionTypes] = None,
    attribute_suggestions_config: Optional[AttributeSuggestionsGetConfig] = None,
) -> GetQuerySuggestionsResponse

Fetches the queries that are suggested to your users.

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

Parameters:

  • index_id (IndexId) –

    The identifier of the index you want to get query suggestions from.

  • query_text (SuggestionQueryText) –

    The text of a user's query to generate query suggestions.

    A query is suggested if the query prefix matches what a user starts to type as their query.

    Amazon Kendra does not show any suggestions if a user types fewer than two characters or more than 60 characters. A query must also have at least one search result and contain at least one word of more than four characters.

  • max_suggestions_count (Optional[Integer], default: None ) –

    The maximum number of query suggestions you want to show to your users.

  • suggestion_types (Optional[SuggestionTypes], default: None ) –

    The suggestions type to base query suggestions on. The suggestion types are query history or document fields/attributes. You can set one type or the other.

    If you set query history as your suggestions type, Amazon Kendra suggests queries relevant to your users based on popular queries in the query history.

    If you set document fields/attributes as your suggestions type, Amazon Kendra suggests queries relevant to your users based on the contents of document fields.

  • attribute_suggestions_config (Optional[AttributeSuggestionsGetConfig], default: None ) –

    Configuration information for the document fields/attributes that you want to base query suggestions on.

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 get_query_suggestions(
    self,
    index_id: "capo_kendra.types.index_id.IndexId",
    query_text: "capo_kendra.types.suggestion_query_text.SuggestionQueryText",
    *,
    config_overrides: Optional[kendraClientConfig] = None,
    max_suggestions_count: Optional["capo_kendra.types.integer.Integer"] = None,
    suggestion_types: Optional[
        "capo_kendra.types.suggestion_types.SuggestionTypes"
    ] = None,
    attribute_suggestions_config: Optional[
        "capo_kendra.types.attribute_suggestions_get_config.AttributeSuggestionsGetConfig"
    ] = None,
) -> "capo_kendra.types.get_query_suggestions_response.GetQuerySuggestionsResponse":
    """<p>Fetches the queries that are suggested to your users.</p> <p> <code>GetQuerySuggestions</code> is currently not supported in the Amazon Web Services GovCloud (US-West) region.</p>

    Args:
        index_id: <p>The identifier of the index you want to get query suggestions from.</p>
        query_text: <p>The text of a user's query to generate query suggestions.</p> <p>A query is suggested if the query prefix matches what a user starts to type as their query.</p> <p>Amazon Kendra does not show any suggestions if a user types fewer than two characters or more than 60 characters. A query must also have at least one search result and contain at least one word of more than four characters.</p>
        max_suggestions_count: <p>The maximum number of query suggestions you want to show to your users.</p>
        suggestion_types: <p>The suggestions type to base query suggestions on. The suggestion types are query history or document fields/attributes. You can set one type or the other.</p> <p>If you set query history as your suggestions type, Amazon Kendra suggests queries relevant to your users based on popular queries in the query history.</p> <p>If you set document fields/attributes as your suggestions type, Amazon Kendra suggests queries relevant to your users based on the contents of document fields.</p>
        attribute_suggestions_config: <p>Configuration information for the document fields/attributes that you want to base query suggestions on.</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.get_query_suggestions_request.GetQuerySuggestionsRequest]",
    ) -> OperationResponse[
        "capo_kendra.types.get_query_suggestions_response.GetQuerySuggestionsResponse"
    ]:
        import capo_kendra._operations.aws_kendra_frontend_service.get_query_suggestions

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetQuerySuggestions")
    )
    input_: capo_kendra.types.get_query_suggestions_request.GetQuerySuggestionsRequest = {
        "index_id": index_id,
        "query_text": query_text,
    }
    if max_suggestions_count is not None:
        input_["max_suggestions_count"] = max_suggestions_count
    if suggestion_types is not None:
        input_["suggestion_types"] = suggestion_types
    if attribute_suggestions_config is not None:
        input_["attribute_suggestions_config"] = attribute_suggestions_config

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