Skip to content

search_relevant_content

search_relevant_content(
    application_id: ApplicationId,
    query_text: QueryText,
    content_source: ContentSource,
    *,
    config_overrides: Optional[QBusinessClientConfig] = None,
    attribute_filter: Optional[AttributeFilter] = None,
    max_results: Optional[MaxResults] = None,
    next_token: Optional[NextToken] = None,
) -> SearchRelevantContentResponse

Searches for relevant content in a Amazon Q Business application based on a query. This operation takes a search query text, the Amazon Q Business application identifier, and optional filters (such as content source and maximum results) as input. It returns a list of relevant content items, where each item includes the content text, the unique document identifier, the document title, the document URI, any relevant document attributes, and score attributes indicating the confidence level of the relevance.

Parameters:

  • application_id (ApplicationId) –

    The unique identifier of the Amazon Q Business application to search.

  • query_text (QueryText) –

    The text to search for.

  • content_source (ContentSource) –

    The source of content to search in.

  • max_results (Optional[MaxResults], default: None ) –

    The maximum number of results to return.

  • next_token (Optional[NextToken], default: None ) –

    The token for the next set of results. (You received this token from a previous call.)

Raises:

  • AccessDeniedException –

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

  • InternalServerException –

    An issue occurred with the internal server used for your Amazon Q Business service. Wait some minutes and try again, or contact Support for help.

  • LicenseNotFoundException –

    You don't have permissions to perform the action because your license is inactive. Ask your admin to activate your license and try again after your licence is active.

  • ResourceNotFoundException –

    The application or plugin resource you want to use doesn’t exist. Make sure you have provided the correct resource and try again.

  • ThrottlingException –

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

  • ValidationException –

    The input doesn't meet the constraints set by the Amazon Q Business service. 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_qbusiness/_services/q_business.py
def search_relevant_content(
    self,
    application_id: "capo_qbusiness.types.application_id.ApplicationId",
    query_text: "capo_qbusiness.types.query_text.QueryText",
    content_source: "capo_qbusiness.types.content_source.ContentSource",
    *,
    config_overrides: Optional[QBusinessClientConfig] = None,
    attribute_filter: Optional[
        "capo_qbusiness.types.attribute_filter.AttributeFilter"
    ] = None,
    max_results: Optional["capo_qbusiness.types.max_results.MaxResults"] = None,
    next_token: Optional["capo_qbusiness.types.next_token.NextToken"] = None,
) -> "capo_qbusiness.types.search_relevant_content_response.SearchRelevantContentResponse":
    """<p>Searches for relevant content in a Amazon Q Business application based on a query. This operation takes a search query text, the Amazon Q Business application identifier, and optional filters (such as content source and maximum results) as input. It returns a list of relevant content items, where each item includes the content text, the unique document identifier, the document title, the document URI, any relevant document attributes, and score attributes indicating the confidence level of the relevance.</p>

    Args:
        application_id: <p>The unique identifier of the Amazon Q Business application to search.</p>
        query_text: <p>The text to search for.</p>
        content_source: <p>The source of content to search in.</p>
        max_results: <p>The maximum number of results to return.</p>
        next_token: <p>The token for the next set of results. (You received this token from a previous call.)</p>

    Raises:
        capo_qbusiness.errors.access_denied_exception.AccessDeniedException: <p> You don't have access to perform this action. Make sure you have the required permission policies and user accounts and try again.</p>
        capo_qbusiness.errors.internal_server_exception.InternalServerException: <p>An issue occurred with the internal server used for your Amazon Q Business service. Wait some minutes and try again, or contact <a href="http://aws.amazon.com/contact-us/">Support</a> for help.</p>
        capo_qbusiness.errors.license_not_found_exception.LicenseNotFoundException: <p>You don't have permissions to perform the action because your license is inactive. Ask your admin to activate your license and try again after your licence is active.</p>
        capo_qbusiness.errors.resource_not_found_exception.ResourceNotFoundException: <p>The application or plugin resource you want to use doesn’t exist. Make sure you have provided the correct resource and try again.</p>
        capo_qbusiness.errors.throttling_exception.ThrottlingException: <p>The request was denied due to throttling. Reduce the number of requests and try again.</p>
        capo_qbusiness.errors.validation_exception.ValidationException: <p>The input doesn't meet the constraints set by the Amazon Q Business service. Provide the correct input and try again.</p>
        capo_qbusiness.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_qbusiness.types.search_relevant_content_request.SearchRelevantContentRequest]",
    ) -> OperationResponse[
        "capo_qbusiness.types.search_relevant_content_response.SearchRelevantContentResponse"
    ]:
        import capo_qbusiness._operations.expert_q.search_relevant_content

        output, http_response = (
            capo_qbusiness._operations.expert_q.search_relevant_content.search_relevant_content(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("SearchRelevantContent")
    )
    input_: capo_qbusiness.types.search_relevant_content_request.SearchRelevantContentRequest = {
        "application_id": application_id,
        "query_text": query_text,
        "content_source": content_source,
    }
    if attribute_filter is not None:
        input_["attribute_filter"] = attribute_filter
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token

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