Skip to content

search_facets async

search_facets(
    *,
    config_overrides: Optional[AsyncMarketplaceDiscoveryClientConfig] = None,
    locale: Optional[Locale] = None,
    search_text: Optional[SearchText] = None,
    filters: Optional[SearchFilterList] = None,
    facet_types: Optional[FacetTypeList] = None,
    next_token: Optional[NextToken] = None,
) -> SearchFacetsOutput

Returns available facet values for filtering listings, such as categories, pricing models, fulfillment option types, publishers, and customer ratings. Each facet value includes a count of matching listings.

Parameters:

  • locale (Optional[Locale], default: None ) –

    A BCP 47 language tag or comma-separated priority list specifying the preferred locale for response content. See Locale for supported values, constraints, fallback behavior, and the default locale. If omitted, the service returns content in the default locale.

  • search_text (Optional[SearchText], default: None ) –

    The search query text to filter listings before retrieving facets.

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

    Filters to apply before retrieving facets. Multiple filters are combined with AND logic. Multiple values within the same filter are combined with OR logic.

  • facet_types (Optional[FacetTypeList], default: None ) –

    A list of specific facet types to retrieve. If empty or null, all available facets are returned.

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

    If nextToken is returned, there are more results available. Make the call again using the returned token to retrieve the next page.

Raises:

Examples:

Get facets for machine learning category Retrieve available facet values for listings in the machine learning category

>>> await client.search_facets(locale='en-US', search_text='analytics', filters=[{'filterType': 'CATEGORY', 'filterValues': ['machine-learning']}], facet_types=['FULFILLMENT_OPTION_TYPE', 'PRICING_MODEL'])
Get facets with term and rating range filters
Retrieve facets for security listings with ratings between 3.0 and 5.0 stars
>>> await client.search_facets(locale='en-US', filters=[{'filterType': 'CATEGORY', 'filterValues': ['security']}, {'filterType': 'MIN_AVERAGE_CUSTOMER_RATING', 'filterValues': ['3.0']}, {'filterType': 'MAX_AVERAGE_CUSTOMER_RATING', 'filterValues': ['5.0']}], facet_types=['PRICING_MODEL', 'AVERAGE_CUSTOMER_RATING'])
Source code in docs_src/capo_marketplace_discovery/_services/async_marketplace_discovery.py
async def search_facets(
    self,
    *,
    config_overrides: Optional[AsyncMarketplaceDiscoveryClientConfig] = None,
    locale: Optional["capo_marketplace_discovery.types.locale.Locale"] = None,
    search_text: Optional[
        "capo_marketplace_discovery.types.search_text.SearchText"
    ] = None,
    filters: Optional[
        "capo_marketplace_discovery.types.search_filter_list.SearchFilterList"
    ] = None,
    facet_types: Optional[
        "capo_marketplace_discovery.types.facet_type_list.FacetTypeList"
    ] = None,
    next_token: Optional[
        "capo_marketplace_discovery.types.next_token.NextToken"
    ] = None,
) -> "capo_marketplace_discovery.types.search_facets_output.SearchFacetsOutput":
    """<p>Returns available facet values for filtering listings, such as categories, pricing models, fulfillment option types, publishers, and customer ratings. Each facet value includes a count of matching listings.</p>

    Args:
        locale: <p>A BCP 47 language tag or comma-separated priority list specifying the preferred locale for response content. See <code>Locale</code> for supported values, constraints, fallback behavior, and the default locale. If omitted, the service returns content in the default locale.</p>
        search_text: <p>The search query text to filter listings before retrieving facets.</p>
        filters: <p>Filters to apply before retrieving facets. Multiple filters are combined with AND logic. Multiple values within the same filter are combined with OR logic.</p>
        facet_types: <p>A list of specific facet types to retrieve. If empty or null, all available facets are returned.</p>
        next_token: <p>If <code>nextToken</code> is returned, there are more results available. Make the call again using the returned token to retrieve the next page.</p>

    Raises:
        capo_marketplace_discovery.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access to perform this action.</p>
        capo_marketplace_discovery.errors.internal_server_exception.InternalServerException: <p>Unexpected error during processing of the request.</p>
        capo_marketplace_discovery.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
        capo_marketplace_discovery.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by the service.</p>
        capo_marketplace_discovery.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Get facets for machine learning category
        Retrieve available facet values for listings in the machine learning category

        >>> await client.search_facets(locale='en-US', search_text='analytics', filters=[{'filterType': 'CATEGORY', 'filterValues': ['machine-learning']}], facet_types=['FULFILLMENT_OPTION_TYPE', 'PRICING_MODEL'])
        Get facets with term and rating range filters
        Retrieve facets for security listings with ratings between 3.0 and 5.0 stars

        >>> await client.search_facets(locale='en-US', filters=[{'filterType': 'CATEGORY', 'filterValues': ['security']}, {'filterType': 'MIN_AVERAGE_CUSTOMER_RATING', 'filterValues': ['3.0']}, {'filterType': 'MAX_AVERAGE_CUSTOMER_RATING', 'filterValues': ['5.0']}], facet_types=['PRICING_MODEL', 'AVERAGE_CUSTOMER_RATING'])
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_marketplace_discovery.types.search_facets_input.SearchFacetsInput]",
    ) -> AsyncOperationResponse[
        "capo_marketplace_discovery.types.search_facets_output.SearchFacetsOutput"
    ]:
        import capo_marketplace_discovery._operations.aws_marketplace_discovery.search_facets

        (
            output,
            http_response,
        ) = await capo_marketplace_discovery._operations.aws_marketplace_discovery.search_facets.async_search_facets(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("SearchFacets")
    )
    input_: capo_marketplace_discovery.types.search_facets_input.SearchFacetsInput = {}
    if locale is not None:
        input_["locale"] = locale
    if search_text is not None:
        input_["search_text"] = search_text
    if filters is not None:
        input_["filters"] = filters
    if facet_types is not None:
        input_["facet_types"] = facet_types
    if next_token is not None:
        input_["next_token"] = next_token

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