Skip to content

search_discoverable_registry_records

search_discoverable_registry_records(
    search_query: SearchQuery,
    registry_ids: RegistryIdList,
    *,
    config_overrides: Optional[AgentRegistryClientConfig] = None,
    max_results: Optional[int] = None,
    filters: Optional[MetadataFilterExpression] = None,
    search_type: Optional[SearchType] = None,
    next_token: Optional[str] = None,
) -> SearchDiscoverableRegistryRecordsResponse

Searches the discoverable registry records in a registry using a natural language query. Returns metadata for the matching records ordered by relevance.

Returns at most 1000 results across all pages when searchType is KEYWORD, and at most 20 results when it is HYBRID or SEMANTIC. To retrieve more records, refine the query or filters, or use ListDiscoverableRegistryRecords to list every record.

Parameters:

  • search_query (SearchQuery) –

    The natural language query to search for matching registry records. If you specify an empty string, the operation returns the records that match the filters, most recently updated first, up to the result limit for the searchType.

  • registry_ids (RegistryIdList) –

    The registry identifiers to search within. Currently, you must specify exactly one registry identifier. You can provide either the full Amazon Web Services Resource Name (ARN) or the registry ID.

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

    The maximum number of results to return in one page. Valid values are 1 through 50 when searchType is KEYWORD, and 1 through 20 when it is HYBRID or SEMANTIC. The default value is 10.

  • filters (Optional[MetadataFilterExpression], default: None ) –

    An optional structured JSON metadata filter that narrows the search results. Supports the field-level operators $eq, $ne, and $in, and the logical operators $and and $or on filterable fields.

    Specifies additional filtering on custom metadata fields using the customMetadata.{key} prefix. For example, to filter by a custom metadata field: {"customMetadata.environment": {"$eq": "production"}}. For a Boolean field, you can also use a native JSON boolean value, for example: {"customMetadata.requiresApproval": {"$eq": true}}.

  • search_type (Optional[SearchType], default: None ) –

    Specifies how the service ranks registry records against the search query. If you omit this parameter, the service uses HYBRID in Amazon Web Services Regions that support semantic search and KEYWORD in Regions that do not. The response reports the search type that the service used. Valid values are the following:

    • KEYWORD – Ranks records by keyword match between the query terms and the record name, description, descriptors, and custom metadata text values. Available in every Amazon Web Services Region.

    • SEMANTIC – Ranks records by semantic similarity to the query and returns the most similar records, up to maxResults, even when none of them closely matches the query.

    • HYBRID – Combines keyword ranking and semantic ranking.

    HYBRID and SEMANTIC are available in a limited number of Regions. If you specify either one in a Region that does not support semantic search, the request fails with a ValidationException that has the reason UnsupportedInRegion.

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

    The pagination token from a previous response. Use it to retrieve the next page of results, and send the same searchQuery, registryIds, filters, and searchType that you used for the first page. If any of them differ, the request fails with a ValidationException. A pagination token expires 15 minutes after the service returns the first page.

Raises:

Source code in docs_src/capo_agent_registry/_services/agent_registry.py
def search_discoverable_registry_records(
    self,
    search_query: "capo_agent_registry.types.search_query.SearchQuery",
    registry_ids: "capo_agent_registry.types.registry_id_list.RegistryIdList",
    *,
    config_overrides: Optional[AgentRegistryClientConfig] = None,
    max_results: Optional[int] = None,
    filters: Optional[
        "capo_agent_registry.types.metadata_filter_expression.MetadataFilterExpression"
    ] = None,
    search_type: Optional[
        "capo_agent_registry.types.search_type.SearchType"
    ] = None,
    next_token: Optional[str] = None,
) -> "capo_agent_registry.types.search_discoverable_registry_records_response.SearchDiscoverableRegistryRecordsResponse":
    """<p> Searches the discoverable registry records in a registry using a natural language query. Returns metadata for the matching records ordered by relevance.</p> <p> Returns at most 1000 results across all pages when <code>searchType</code> is <code>KEYWORD</code>, and at most 20 results when it is <code>HYBRID</code> or <code>SEMANTIC</code>. To retrieve more records, refine the query or filters, or use <code>ListDiscoverableRegistryRecords</code> to list every record.</p>

    Args:
        search_query: <p> The natural language query to search for matching registry records. If you specify an empty string, the operation returns the records that match the <code>filters</code>, most recently updated first, up to the result limit for the <code>searchType</code>.</p>
        registry_ids: <p> The registry identifiers to search within. Currently, you must specify exactly one registry identifier. You can provide either the full Amazon Web Services Resource Name (ARN) or the registry ID.</p>
        max_results: <p> The maximum number of results to return in one page. Valid values are 1 through 50 when <code>searchType</code> is <code>KEYWORD</code>, and 1 through 20 when it is <code>HYBRID</code> or <code>SEMANTIC</code>. The default value is 10.</p>
        filters: <p> An optional structured JSON metadata filter that narrows the search results. Supports the field-level operators <code>$eq</code>, <code>$ne</code>, and <code>$in</code>, and the logical operators <code>$and</code> and <code>$or</code> on filterable fields.</p> <p> Specifies additional filtering on custom metadata fields using the <code>customMetadata.{key}</code> prefix. For example, to filter by a custom metadata field: <code>{"customMetadata.environment": {"$eq": "production"}}</code>. For a Boolean field, you can also use a native JSON boolean value, for example: <code>{"customMetadata.requiresApproval": {"$eq": true}}</code>.</p>
        search_type: <p> Specifies how the service ranks registry records against the search query. If you omit this parameter, the service uses <code>HYBRID</code> in Amazon Web Services Regions that support semantic search and <code>KEYWORD</code> in Regions that do not. The response reports the search type that the service used. Valid values are the following:</p> <ul> <li> <p> <code>KEYWORD</code> – Ranks records by keyword match between the query terms and the record name, description, descriptors, and custom metadata text values. Available in every Amazon Web Services Region.</p> </li> <li> <p> <code>SEMANTIC</code> – Ranks records by semantic similarity to the query and returns the most similar records, up to <code>maxResults</code>, even when none of them closely matches the query.</p> </li> <li> <p> <code>HYBRID</code> – Combines keyword ranking and semantic ranking.</p> </li> </ul> <p> <code>HYBRID</code> and <code>SEMANTIC</code> are available in a limited number of Regions. If you specify either one in a Region that does not support semantic search, the request fails with a <code>ValidationException</code> that has the reason <code>UnsupportedInRegion</code>.</p>
        next_token: <p> The pagination token from a previous response. Use it to retrieve the next page of results, and send the same <code>searchQuery</code>, <code>registryIds</code>, <code>filters</code>, and <code>searchType</code> that you used for the first page. If any of them differ, the request fails with a <code>ValidationException</code>. A pagination token expires 15 minutes after the service returns the first page.</p>

    Raises:
        capo_agent_registry.errors.access_denied_exception.AccessDeniedException: <p>The caller is not authorized to perform the requested action.</p>
        capo_agent_registry.errors.internal_server_exception.InternalServerException: <p>The request failed due to an unexpected internal error; the caller may retry.</p>
        capo_agent_registry.errors.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource was not found.</p>
        capo_agent_registry.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling; the caller may retry after a delay.</p>
        capo_agent_registry.errors.unauthorized_exception.UnauthorizedException: <p>The request could not be authenticated.</p>
        capo_agent_registry.errors.validation_exception.ValidationException: <p>The request failed validation of one or more input fields.</p>
        capo_agent_registry.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_agent_registry.types.search_discoverable_registry_records_request.SearchDiscoverableRegistryRecordsRequest]",
    ) -> OperationResponse[
        "capo_agent_registry.types.search_discoverable_registry_records_response.SearchDiscoverableRegistryRecordsResponse"
    ]:
        import capo_agent_registry._operations.agent_registry.search_discoverable_registry_records

        output, http_response = (
            capo_agent_registry._operations.agent_registry.search_discoverable_registry_records.search_discoverable_registry_records(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_agent_registry.types.search_discoverable_registry_records_request.SearchDiscoverableRegistryRecordsRequest",
    ) -> dict[str, Any]:
        import capo_agent_registry.types.search_discoverable_registry_records_request

        return capo_agent_registry.types.search_discoverable_registry_records_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_agent_registry.types.search_discoverable_registry_records_response.SearchDiscoverableRegistryRecordsResponse",
    ) -> dict[str, Any]:
        import capo_agent_registry.types.search_discoverable_registry_records_response

        return capo_agent_registry.types.search_discoverable_registry_records_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "SearchDiscoverableRegistryRecords",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_agent_registry.types.search_discoverable_registry_records_request.SearchDiscoverableRegistryRecordsRequest = {
        "search_query": search_query,
        "registry_ids": registry_ids,
    }
    if max_results is not None:
        input_["max_results"] = max_results
    if filters is not None:
        input_["filters"] = filters
    if search_type is not None:
        input_["search_type"] = search_type
    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