Skip to content

search_text

search_text(
    *,
    config_overrides: Optional[GeoPlacesClientConfig] = None,
    query_text: Optional[SensitiveString] = None,
    query_id: Optional[SensitiveString] = None,
    max_results: Optional[int] = None,
    bias_position: Optional[Position] = None,
    filter: Optional[SearchTextFilter] = None,
    additional_features: Optional[SearchTextAdditionalFeatureList] = None,
    language: Optional[LanguageTag] = None,
    political_view: Optional[CountryCode] = None,
    intended_use: Optional[SearchTextIntendedUse] = None,
    next_token: Optional[Token] = None,
    travel_mode: Optional[SearchTextTravelMode] = None,
    key: Optional[ApiKey] = None,
) -> SearchTextResponse

SearchText searches for geocode and place information. You can then complete a follow-up query suggested from the Suggest API via a query id.

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

Parameters:

  • query_text (Optional[SensitiveString], default: None ) –

    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.

    Exactly one of the following fields must be set: QueryText or QueryId.

  • query_id (Optional[SensitiveString], default: None ) –

    The query Id returned by the suggest API. If passed in the request, the SearchText API will preform a SearchText query with the improved query terms for the original query made to the suggest API. Not available in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

    Exactly one of the following fields must be set: QueryText or QueryId.

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

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

    Default value: 20

  • 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.

    Exactly one of the following fields must be set: BiasPosition, Filter.BoundingBox, or Filter.Circle.

  • filter (Optional[SearchTextFilter], 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[SearchTextAdditionalFeatureList], 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 TimeZone value.

  • 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 available in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

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

    Indicates if the query results will be persisted in customer infrastructure. Defaults to SingleUse (not stored).

    When storing SearchText responses, you must set this field to Storage to comply with the terms of service. These requests will be charged at a higher rate. Please review the user agreement and service pricing structure to determine the correct setting for your use case.

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

    If nextToken is returned, there are more results available. The value of nextToken is a unique pagination token for each page.

  • travel_mode (Optional[SearchTextTravelMode], 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/geo_places.py
def search_text(
    self,
    *,
    config_overrides: Optional[GeoPlacesClientConfig] = None,
    query_text: Optional[
        "capo_geo_places.types.sensitive_string.SensitiveString"
    ] = None,
    query_id: Optional[
        "capo_geo_places.types.sensitive_string.SensitiveString"
    ] = None,
    max_results: Optional[int] = None,
    bias_position: Optional["capo_geo_places.types.position.Position"] = None,
    filter: Optional[
        "capo_geo_places.types.search_text_filter.SearchTextFilter"
    ] = None,
    additional_features: Optional[
        "capo_geo_places.types.search_text_additional_feature_list.SearchTextAdditionalFeatureList"
    ] = 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.search_text_intended_use.SearchTextIntendedUse"
    ] = None,
    next_token: Optional["capo_geo_places.types.token.Token"] = None,
    travel_mode: Optional[
        "capo_geo_places.types.search_text_travel_mode.SearchTextTravelMode"
    ] = None,
    key: Optional["capo_geo_places.types.api_key.ApiKey"] = None,
) -> "capo_geo_places.types.search_text_response.SearchTextResponse":
    """<p> <code>SearchText</code> searches for geocode and place information. You can then complete a follow-up query suggested from the <code>Suggest</code> API via a query id.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/location/latest/developerguide/search-text.html">Search Text</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>Exactly one of the following fields must be set: <code>QueryText</code> or <code>QueryId</code>.</p> </note>
        query_id: <p>The query Id returned by the suggest API. If passed in the request, the SearchText API will preform a SearchText query with the improved query terms for the original query made to the suggest API. Not available 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> <note> <p>Exactly one of the following fields must be set: <code>QueryText</code> or <code>QueryId</code>.</p> </note>
        max_results: <p>An optional limit for the number of results returned in a single call.</p> <p>Default value: 20</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>Exactly one of the following fields must be set: <code>BiasPosition</code>, <code>Filter.BoundingBox</code>, or <code>Filter.Circle</code>.</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>TimeZone</code> value.</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 available 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). </p> <note> <p>When storing <code>SearchText</code> responses, you <i>must</i> set this field to <code>Storage</code> to comply with the terms of service. These requests will be charged at a higher rate. Please review the <a href="https://aws.amazon.com/location/sla/">user agreement</a> and <a href="https://aws.amazon.com/location/pricing/">service pricing structure</a> to determine the correct setting for your use case.</p> </note>
        next_token: <p>If <code>nextToken</code> is returned, there are more results available. The value of <code>nextToken</code> is a unique pagination token for each page. </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.
    """

    def _handler(
        req: "OperationRequest[capo_geo_places.types.search_text_request.SearchTextRequest]",
    ) -> OperationResponse[
        "capo_geo_places.types.search_text_response.SearchTextResponse"
    ]:
        import capo_geo_places._operations.places_service.search_text

        output, http_response = (
            capo_geo_places._operations.places_service.search_text.search_text(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

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

        return capo_geo_places.types.search_text_request.redact_sensitive(input_)

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

        return capo_geo_places.types.search_text_response.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "SearchText", redact_input=_redact_input, redact_output=_redact_output
        ),
    )
    input_: capo_geo_places.types.search_text_request.SearchTextRequest = {}
    if query_text is not None:
        input_["query_text"] = query_text
    if query_id is not None:
        input_["query_id"] = query_id
    if max_results is not None:
        input_["max_results"] = max_results
    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 next_token is not None:
        input_["next_token"] = next_token
    if travel_mode is not None:
        input_["travel_mode"] = travel_mode
    if key is not None:
        input_["key"] = key

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