Skip to content

suggest async

suggest(
    query_text: SensitiveString,
    *,
    config_overrides: Optional[AsyncGeoPlacesClientConfig] = None,
    max_results: Optional[int] = None,
    max_query_refinements: Optional[int] = None,
    bias_position: Optional[Position] = None,
    filter: Optional[SuggestFilter] = None,
    additional_features: Optional[SuggestAdditionalFeatureList] = None,
    language: Optional[LanguageTag] = None,
    political_view: Optional[CountryCode] = None,
    intended_use: Optional[SuggestIntendedUse] = None,
    travel_mode: Optional[SuggestTravelMode] = None,
    key: Optional[ApiKey] = None,
) -> SuggestResponse

Suggest provides intelligent predictions or recommendations based on the user's input or context, such as relevant places, points of interest, query terms or search category. It is designed to help users find places or point of interests candidates or identify a follow on query based on incomplete or misspelled queries. It returns a list of possible matches or refinements that can be used to formulate a more accurate query. Users can select the most appropriate suggestion and use it for further searching. The API provides options for filtering results by location and other attributes, and allows for additional features like phonemes and timezones. The response includes refined query terms and detailed place information.

For more information, see Suggest in the Amazon Location Service Developer Guide.

Parameters:

  • query_text (SensitiveString) –

    The free-form text query to match addresses against. This is usually a partially typed address from an end user in an address box or form.

    The fields QueryText and QueryID are mutually exclusive.

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

    An optional limit for the number of results returned in a single call.

    Default value: 20

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

    Maximum number of query terms to be returned for use with a search text query. Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

  • bias_position (Optional[Position], default: None ) –

    The position, in longitude and latitude, that the results should be close to. Typically, place results returned are ranked higher the closer they are to this position. Stored in [lng, lat] and in the WGS 84 format.

    The fields BiasPosition, FilterBoundingBox, and FilterCircle are mutually exclusive.

  • filter (Optional[SuggestFilter], default: None ) –

    A structure which contains a set of inclusion/exclusion properties that results must possess in order to be returned as a result.

  • additional_features (Optional[SuggestAdditionalFeatureList], default: None ) –

    A list of optional additional parameters, such as time zone, that can be requested for each result. For GrabMaps customers, ap-southeast-1 and ap-southeast-5 regions support only the Core and TimeZone values.

  • language (Optional[LanguageTag], default: None ) –

    A list of BCP 47 compliant language codes for the results to be rendered in. If there is no data for the result in the requested language, data will be returned in the default language for the entry. For GrabMaps customers, ap-southeast-1 and ap-southeast-5 regions support only the following codes: en, id, km, lo, ms, my, pt, th, tl, vi, zh

  • political_view (Optional[CountryCode], default: None ) –

    The alpha-2 or alpha-3 character code for the political view of a country. The political view applies to the results of the request to represent unresolved territorial claims through the point of view of the specified country. Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

  • intended_use (Optional[SuggestIntendedUse], default: None ) –

    Indicates if the query results will be persisted in customer infrastructure. Defaults to SingleUse (not stored). Currently, Suggest does not support storage of results.

  • travel_mode (Optional[SuggestTravelMode], default: None ) –

    Indicates the mode of mobility used by the end user. This is used to improve the relevance of search results. Valid values are Car, Scooter, and Truck.

  • key (Optional[ApiKey], default: None ) –

    Optional: The API key to be used for authorization. Either an API key or valid SigV4 signature must be provided when making a request.

Raises:

Source code in docs_src/capo_geo_places/_services/async_geo_places.py
async def suggest(
    self,
    query_text: "capo_geo_places.types.sensitive_string.SensitiveString",
    *,
    config_overrides: Optional[AsyncGeoPlacesClientConfig] = None,
    max_results: Optional[int] = None,
    max_query_refinements: Optional[int] = None,
    bias_position: Optional["capo_geo_places.types.position.Position"] = None,
    filter: Optional["capo_geo_places.types.suggest_filter.SuggestFilter"] = None,
    additional_features: Optional[
        "capo_geo_places.types.suggest_additional_feature_list.SuggestAdditionalFeatureList"
    ] = None,
    language: Optional["capo_geo_places.types.language_tag.LanguageTag"] = None,
    political_view: Optional[
        "capo_geo_places.types.country_code.CountryCode"
    ] = None,
    intended_use: Optional[
        "capo_geo_places.types.suggest_intended_use.SuggestIntendedUse"
    ] = None,
    travel_mode: Optional[
        "capo_geo_places.types.suggest_travel_mode.SuggestTravelMode"
    ] = None,
    key: Optional["capo_geo_places.types.api_key.ApiKey"] = None,
) -> "capo_geo_places.types.suggest_response.SuggestResponse":
    """<p> <code>Suggest</code> provides intelligent predictions or recommendations based on the user's input or context, such as relevant places, points of interest, query terms or search category. It is designed to help users find places or point of interests candidates or identify a follow on query based on incomplete or misspelled queries. It returns a list of possible matches or refinements that can be used to formulate a more accurate query. Users can select the most appropriate suggestion and use it for further searching. The API provides options for filtering results by location and other attributes, and allows for additional features like phonemes and timezones. The response includes refined query terms and detailed place information.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/location/latest/developerguide/suggest.html">Suggest</a> in the <i>Amazon Location Service Developer Guide</i>.</p>

    Args:
        query_text: <p>The free-form text query to match addresses against. This is usually a partially typed address from an end user in an address box or form.</p> <note> <p>The fields <code>QueryText</code> and <code>QueryID</code> are mutually exclusive.</p> </note>
        max_results: <p> An optional limit for the number of results returned in a single call. </p> <p>Default value: 20</p>
        max_query_refinements: <p> Maximum number of query terms to be returned for use with a search text query. Not supported in <code>ap-southeast-1</code> and <code>ap-southeast-5</code> regions for <a href="https://docs.aws.amazon.com/location/latest/developerguide/GrabMaps.html">GrabMaps</a> customers. </p>
        bias_position: <p>The position, in longitude and latitude, that the results should be close to. Typically, place results returned are ranked higher the closer they are to this position. Stored in <code>[lng, lat]</code> and in the WGS 84 format.</p> <note> <p>The fields <code>BiasPosition</code>, <code>FilterBoundingBox</code>, and <code>FilterCircle</code> are mutually exclusive.</p> </note>
        filter: <p>A structure which contains a set of inclusion/exclusion properties that results must possess in order to be returned as a result.</p>
        additional_features: <p> A list of optional additional parameters, such as time zone, that can be requested for each result. For <a href="https://docs.aws.amazon.com/location/latest/developerguide/GrabMaps.html">GrabMaps</a> customers, <code>ap-southeast-1</code> and <code>ap-southeast-5</code> regions support only the <code>Core</code> and <code>TimeZone</code> values. </p>
        language: <p> A list of <a href="https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry">BCP 47</a> compliant language codes for the results to be rendered in. If there is no data for the result in the requested language, data will be returned in the default language for the entry. For <a href="https://docs.aws.amazon.com/location/latest/developerguide/GrabMaps.html">GrabMaps</a> customers, <code>ap-southeast-1</code> and <code>ap-southeast-5</code> regions support only the following codes: <code>en, id, km, lo, ms, my, pt, th, tl, vi, zh</code> </p>
        political_view: <p> The alpha-2 or alpha-3 character code for the political view of a country. The political view applies to the results of the request to represent unresolved territorial claims through the point of view of the specified country. Not supported in <code>ap-southeast-1</code> and <code>ap-southeast-5</code> regions for <a href="https://docs.aws.amazon.com/location/latest/developerguide/GrabMaps.html">GrabMaps</a> customers. </p>
        intended_use: <p> Indicates if the query results will be persisted in customer infrastructure. Defaults to <code>SingleUse</code> (not stored). Currently, <code>Suggest</code> does not support storage of results. </p>
        travel_mode: <p>Indicates the mode of mobility used by the end user. This is used to improve the relevance of search results. Valid values are <code>Car</code>, <code>Scooter</code>, and <code>Truck</code>.</p>
        key: <p>Optional: The API key to be used for authorization. Either an API key or valid SigV4 signature must be provided when making a request.</p>

    Raises:
        capo_geo_places.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access to perform this action.</p>
        capo_geo_places.errors.internal_server_exception.InternalServerException: <p>The request processing has failed because of an unknown error, exception or failure.</p>
        capo_geo_places.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
        capo_geo_places.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by an AWS service.</p>
        capo_geo_places.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_geo_places.types.suggest_request.SuggestRequest]",
    ) -> AsyncOperationResponse[
        "capo_geo_places.types.suggest_response.SuggestResponse"
    ]:
        import capo_geo_places._operations.places_service.suggest

        (
            output,
            http_response,
        ) = await capo_geo_places._operations.places_service.suggest.async_suggest(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_geo_places.types.suggest_request.SuggestRequest",
    ) -> dict[str, Any]:
        import capo_geo_places.types.suggest_request

        return capo_geo_places.types.suggest_request.redact_sensitive(input_)

    def _redact_output(
        output: "capo_geo_places.types.suggest_response.SuggestResponse",
    ) -> dict[str, Any]:
        import capo_geo_places.types.suggest_response

        return capo_geo_places.types.suggest_response.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "Suggest", redact_input=_redact_input, redact_output=_redact_output
        ),
    )
    input_: capo_geo_places.types.suggest_request.SuggestRequest = {
        "query_text": query_text
    }
    if max_results is not None:
        input_["max_results"] = max_results
    if max_query_refinements is not None:
        input_["max_query_refinements"] = max_query_refinements
    if bias_position is not None:
        input_["bias_position"] = bias_position
    if filter is not None:
        input_["filter"] = filter
    if additional_features is not None:
        input_["additional_features"] = additional_features
    if language is not None:
        input_["language"] = language
    if political_view is not None:
        input_["political_view"] = political_view
    if intended_use is not None:
        input_["intended_use"] = intended_use
    if travel_mode is not None:
        input_["travel_mode"] = travel_mode
    if key is not None:
        input_["key"] = key

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