Skip to content

search_place_index_for_text async

search_place_index_for_text(
    index_name: ResourceName,
    text: SensitiveString,
    *,
    config_overrides: Optional[AsyncLocationClientConfig] = None,
    bias_position: Optional[Position] = None,
    filter_b_box: Optional[BoundingBox] = None,
    filter_countries: Optional[CountryCodeList] = None,
    max_results: Optional[PlaceIndexSearchResultLimit] = None,
    language: Optional[LanguageTag] = None,
    filter_categories: Optional[FilterPlaceCategoryList] = None,
    key: Optional[ApiKey] = None,
) -> SearchPlaceIndexForTextResponse

This operation is no longer current and may be deprecated in the future. We recommend you upgrade to Geocode or SearchText unless you require Grab data.

  • SearchPlaceIndexForText is part of a previous Amazon Location Service Places API (version 1) which has been superseded by a more intuitive, powerful, and complete API (version 2).

  • The version 2 Geocode operation gives better results in the address geocoding use case, while the version 2 SearchText operation gives better results when searching for businesses and points of interest.

  • If you are using an Amazon Web Services SDK or the Amazon Web Services CLI, note that the Places API version 2 is found under geo-places or geo_places, not under location.

  • Since Grab is not yet fully supported in Places API version 2, we recommend you continue using API version 1 when using Grab.

Geocodes free-form text, such as an address, name, city, or region to allow you to search for Places or points of interest.

Optional parameters let you narrow your search results by bounding box or country, or bias your search toward a specific position on the globe.

You can search for places near a given position using BiasPosition, or filter results within a bounding box using FilterBBox. Providing both parameters simultaneously returns an error.

Search results are returned in order of highest to lowest relevance.

Parameters:

  • index_name (ResourceName) –

    The name of the place index resource you want to use for the search.

  • text (SensitiveString) –

    The address, name, city, or region to be used in the search in free-form text format. For example, 123 Any Street.

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

    An optional parameter that indicates a preference for places that are closer to a specified position.

    If provided, this parameter must contain a pair of numbers. The first number represents the X coordinate, or longitude; the second number represents the Y coordinate, or latitude.

    For example, [-123.1174, 49.2847] represents the position with longitude -123.1174 and latitude 49.2847.

    BiasPosition and FilterBBox are mutually exclusive. Specifying both options results in an error.

  • filter_b_box (Optional[BoundingBox], default: None ) –

    An optional parameter that limits the search results by returning only places that are within the provided bounding box.

    If provided, this parameter must contain a total of four consecutive numbers in two pairs. The first pair of numbers represents the X and Y coordinates (longitude and latitude, respectively) of the southwest corner of the bounding box; the second pair of numbers represents the X and Y coordinates (longitude and latitude, respectively) of the northeast corner of the bounding box.

    For example, [-12.7935, -37.4835, -12.0684, -36.9542] represents a bounding box where the southwest corner has longitude -12.7935 and latitude -37.4835, and the northeast corner has longitude -12.0684 and latitude -36.9542.

    FilterBBox and BiasPosition are mutually exclusive. Specifying both options results in an error.

  • filter_countries (Optional[CountryCodeList], default: None ) –

    An optional parameter that limits the search results by returning only places that are in a specified list of countries.

    • Valid values include ISO 3166 3-digit country codes. For example, Australia uses three upper-case characters: AUS.

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

    An optional parameter. The maximum number of results returned per request.

    The default: 50

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

    The preferred language used to return results. The value must be a valid BCP 47 language tag, for example, en for English.

    This setting affects the languages used in the results, but not the results themselves. If no language is specified, or not supported for a particular result, the partner automatically chooses a language for the result.

    For an example, we'll use the Greek language. You search for Athens, Greece, with the language parameter set to en. The result found will most likely be returned as Athens.

    If you set the language parameter to el, for Greek, then the result found will more likely be returned as Αθήνα.

    If the data provider does not have a value for Greek, the result will be in a language that the provider does support.

  • filter_categories (Optional[FilterPlaceCategoryList], default: None ) –

    A list of one or more Amazon Location categories to filter the returned places. If you include more than one category, the results will include results that match any of the categories listed.

    For more information about using categories, including a list of Amazon Location categories, see Categories and filtering, in the Amazon Location Service developer guide.

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

    The optional API key to authorize the request.

Raises:

  • AccessDeniedException –

    The request was denied because of insufficient access or permissions. Check with an administrator to verify your permissions.

  • InternalServerException –

    The request has failed to process because of an unknown server error, exception, or failure.

  • ResourceNotFoundException –

    The resource that you've entered was not found in your AWS account.

  • ThrottlingException –

    The request was denied because of request throttling.

  • ValidationException –

    The input failed to meet the constraints specified by the AWS service.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_location/_services/async_location.py
async def search_place_index_for_text(
    self,
    index_name: "capo_location.types.resource_name.ResourceName",
    text: "capo_location.types.sensitive_string.SensitiveString",
    *,
    config_overrides: Optional[AsyncLocationClientConfig] = None,
    bias_position: Optional["capo_location.types.position.Position"] = None,
    filter_b_box: Optional["capo_location.types.bounding_box.BoundingBox"] = None,
    filter_countries: Optional[
        "capo_location.types.country_code_list.CountryCodeList"
    ] = None,
    max_results: Optional[
        "capo_location.types.place_index_search_result_limit.PlaceIndexSearchResultLimit"
    ] = None,
    language: Optional["capo_location.types.language_tag.LanguageTag"] = None,
    filter_categories: Optional[
        "capo_location.types.filter_place_category_list.FilterPlaceCategoryList"
    ] = None,
    key: Optional["capo_location.types.api_key.ApiKey"] = None,
) -> "capo_location.types.search_place_index_for_text_response.SearchPlaceIndexForTextResponse":
    """<important> <p>This operation is no longer current and may be deprecated in the future. We recommend you upgrade to <a href="/location/latest/APIReference/API_geoplaces_Geocode.html"> <code>Geocode</code> </a> or <a href="/location/latest/APIReference/API_geoplaces_SearchText.html"> <code>SearchText</code> </a> unless you require Grab data.</p> <ul> <li> <p> <code>SearchPlaceIndexForText</code> is part of a previous Amazon Location Service Places API (version 1) which has been superseded by a more intuitive, powerful, and complete API (version 2).</p> </li> <li> <p>The version 2 <code>Geocode</code> operation gives better results in the address geocoding use case, while the version 2 <code>SearchText</code> operation gives better results when searching for businesses and points of interest.</p> </li> <li> <p>If you are using an Amazon Web Services SDK or the Amazon Web Services CLI, note that the Places API version 2 is found under <code>geo-places</code> or <code>geo_places</code>, not under <code>location</code>.</p> </li> <li> <p>Since Grab is not yet fully supported in Places API version 2, we recommend you continue using API version 1 when using Grab.</p> </li> </ul> </important> <p>Geocodes free-form text, such as an address, name, city, or region to allow you to search for Places or points of interest. </p> <p>Optional parameters let you narrow your search results by bounding box or country, or bias your search toward a specific position on the globe.</p> <note> <p>You can search for places near a given position using <code>BiasPosition</code>, or filter results within a bounding box using <code>FilterBBox</code>. Providing both parameters simultaneously returns an error.</p> </note> <p>Search results are returned in order of highest to lowest relevance.</p>

    Args:
        index_name: <p>The name of the place index resource you want to use for the search.</p>
        text: <p>The address, name, city, or region to be used in the search in free-form text format. For example, <code>123 Any Street</code>.</p>
        bias_position: <p>An optional parameter that indicates a preference for places that are closer to a specified position.</p> <p> If provided, this parameter must contain a pair of numbers. The first number represents the X coordinate, or longitude; the second number represents the Y coordinate, or latitude.</p> <p>For example, <code>[-123.1174, 49.2847]</code> represents the position with longitude <code>-123.1174</code> and latitude <code>49.2847</code>.</p> <note> <p> <code>BiasPosition</code> and <code>FilterBBox</code> are mutually exclusive. Specifying both options results in an error. </p> </note>
        filter_b_box: <p>An optional parameter that limits the search results by returning only places that are within the provided bounding box.</p> <p> If provided, this parameter must contain a total of four consecutive numbers in two pairs. The first pair of numbers represents the X and Y coordinates (longitude and latitude, respectively) of the southwest corner of the bounding box; the second pair of numbers represents the X and Y coordinates (longitude and latitude, respectively) of the northeast corner of the bounding box.</p> <p>For example, <code>[-12.7935, -37.4835, -12.0684, -36.9542]</code> represents a bounding box where the southwest corner has longitude <code>-12.7935</code> and latitude <code>-37.4835</code>, and the northeast corner has longitude <code>-12.0684</code> and latitude <code>-36.9542</code>.</p> <note> <p> <code>FilterBBox</code> and <code>BiasPosition</code> are mutually exclusive. Specifying both options results in an error. </p> </note>
        filter_countries: <p>An optional parameter that limits the search results by returning only places that are in a specified list of countries.</p> <ul> <li> <p>Valid values include <a href="https://www.iso.org/iso-3166-country-codes.html">ISO 3166</a> 3-digit country codes. For example, Australia uses three upper-case characters: <code>AUS</code>.</p> </li> </ul>
        max_results: <p>An optional parameter. The maximum number of results returned per request. </p> <p>The default: <code>50</code> </p>
        language: <p>The preferred language used to return results. The value must be a valid <a href="https://tools.ietf.org/search/bcp47">BCP 47</a> language tag, for example, <code>en</code> for English.</p> <p>This setting affects the languages used in the results, but not the results themselves. If no language is specified, or not supported for a particular result, the partner automatically chooses a language for the result.</p> <p>For an example, we'll use the Greek language. You search for <code>Athens, Greece</code>, with the <code>language</code> parameter set to <code>en</code>. The result found will most likely be returned as <code>Athens</code>.</p> <p>If you set the <code>language</code> parameter to <code>el</code>, for Greek, then the result found will more likely be returned as <code>Αθήνα</code>.</p> <p>If the data provider does not have a value for Greek, the result will be in a language that the provider does support.</p>
        filter_categories: <p>A list of one or more Amazon Location categories to filter the returned places. If you include more than one category, the results will include results that match <i>any</i> of the categories listed.</p> <p>For more information about using categories, including a list of Amazon Location categories, see <a href="https://docs.aws.amazon.com/location/previous/developerguide/category-filtering.html">Categories and filtering</a>, in the <i>Amazon Location Service developer guide</i>.</p>
        key: <p>The optional <a href="https://docs.aws.amazon.com/location/previous/developerguide/using-apikeys.html">API key</a> to authorize the request.</p>

    Raises:
        capo_location.errors.access_denied_exception.AccessDeniedException: <p>The request was denied because of insufficient access or permissions. Check with an administrator to verify your permissions.</p>
        capo_location.errors.internal_server_exception.InternalServerException: <p>The request has failed to process because of an unknown server error, exception, or failure.</p>
        capo_location.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource that you've entered was not found in your AWS account.</p>
        capo_location.errors.throttling_exception.ThrottlingException: <p>The request was denied because of request throttling.</p>
        capo_location.errors.validation_exception.ValidationException: <p>The input failed to meet the constraints specified by the AWS service. </p>
        capo_location.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_location.types.search_place_index_for_text_request.SearchPlaceIndexForTextRequest]",
    ) -> AsyncOperationResponse[
        "capo_location.types.search_place_index_for_text_response.SearchPlaceIndexForTextResponse"
    ]:
        import capo_location._operations.location_service.search_place_index_for_text

        (
            output,
            http_response,
        ) = await capo_location._operations.location_service.search_place_index_for_text.async_search_place_index_for_text(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_location.types.search_place_index_for_text_request.SearchPlaceIndexForTextRequest",
    ) -> dict[str, Any]:
        import capo_location.types.search_place_index_for_text_request

        return capo_location.types.search_place_index_for_text_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_location.types.search_place_index_for_text_response.SearchPlaceIndexForTextResponse",
    ) -> dict[str, Any]:
        import capo_location.types.search_place_index_for_text_response

        return capo_location.types.search_place_index_for_text_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "SearchPlaceIndexForText",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_location.types.search_place_index_for_text_request.SearchPlaceIndexForTextRequest = {
        "index_name": index_name,
        "text": text,
    }
    if bias_position is not None:
        input_["bias_position"] = bias_position
    if filter_b_box is not None:
        input_["filter_b_box"] = filter_b_box
    if filter_countries is not None:
        input_["filter_countries"] = filter_countries
    if max_results is not None:
        input_["max_results"] = max_results
    if language is not None:
        input_["language"] = language
    if filter_categories is not None:
        input_["filter_categories"] = filter_categories
    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