Text Search (New)

  • Google Maps Places API Text Search finds places using text queries, handling imprecise addresses and finding businesses by name or type.

  • Text Search supports various parameters to refine searches, like location restrictions, price levels, and open hours filters.

  • Search results are ranked by relevance or distance, depending on the query and parameters used.

  • Requests specify desired data fields, affecting billing based on the selected information.

  • This feature is part of the Places SDK for Android (New), and developers should be aware of version differences and billing considerations.

European Economic Area (EEA) developers If your billing address is in the European Economic Area, effective on 8 July 2025, the Google Maps Platform EEA Terms of Service will apply to your use of the Services. Functionality varies by region.Learn more.

Text Search (New) returns information about a set of places based on astring (for example, "pizza in New York" or "shoe stores near Ottawa" or "123Main Street"). The service responds with a list of places matching the textstring and any location bias that has been set.

In addition torequired parameters,Text Search (New) supports refining queries usingoptionalparameters for better results.

Text Search (New) is similar toNearby Search(New). The maindifference between the two is that Text Search (New)lets you specify an arbitrary search string while Nearby Search (New) requires aspecific area in which to search.

Note: Text Search (New) is available in Places SDK forAndroid version 3.3.0 and later. For more information, seeChoose your SDKversion. For moreinformation about using the Kotlin APIs added in version4.0.0, see theReferenceOverview.

Text Search requests

Note: Text Search is part ofPlaces SDK for Android (New) and is not available inPlaces SDK for Android.

A Text Search request is in the form:

// Specify the list of fields to return.finalList<Place.Field>placeFields=Arrays.asList(Place.Field.ID,Place.Field.DISPLAY_NAME);// Define latitude and longitude coordinates of the search area.LatLngsouthWest=newLatLng(37.38816277477739,-122.08813770258874);LatLngnorthEast=newLatLng(37.39580487866437,-122.07702325966572);// Use the builder to create a SearchByTextRequest object.finalSearchByTextRequestsearchByTextRequest=SearchByTextRequest.builder("Spicy Vegetarian Food",placeFields).setMaxResultCount(10).setLocationRestriction(RectangularBounds.newInstance(southWest,northEast)).build();// Call PlacesClient.searchByText() to perform the search.// Define a response handler to process the returned List of Place objects.placesClient.searchByText(searchByTextRequest).addOnSuccessListener(response->{List<Place>places=response.getPlaces();});

In this example, you:

Note: For more information on initializingPlacesClient, seeInitialize the Places API client.

You can use aCancellationTokento attempt to cancel a request to any of the request classes (for example,FetchPlaceRequest). Cancellation is done on a best-effort basis.Once a cancellation request is issued, no response will be returned.Issuing a cancellation token does NOT guarantee that a particular requestwill be cancelled, and you may still be charged for the request even if noresponse is returned.

Text Search responses

TheSearchByTextResponseclass represents the response from a search request. ASearchByTextResponseobject contains:

  • A list ofPlace objects that represent all matching places, with onePlace object per matching place.

  • EachPlace object only contains the fields defined by the field listpassed in the request.

For example, in the request you defined a field list as:

// Specify the list of fields to return.finalList<Place.Field>placeFields=Arrays.asList(Place.Field.ID,Place.Field.DISPLAY_NAME);

This field list means that eachPlace object in the response contains only theplace ID and name of each matching place. You can then use thePlace.getId()andPlace.getName() methods to access these fields in eachPlace object.

For more examples of accessing data in aPlace object, seeAccess Placeobject data fields

Pagination

Text Search'sSearchByTextResponse class provides access to text search result pagination through itsgetPagination() method, which returns a Pagination object.

Use the Pagination object'shasNextPage() method to determine if additional pages of results are available. This method returns a boolean value (true or false).

WhilehasNextPage() returns true, call thefetchNextPage() method to retrieve the next page of results.

The following example shows how to check if a next page is available, and thenload the page.

Kotlin

valsearchByTextRequest=searchByTextRequest("restaurants",Arrays.asList(Place.Field.NAME)){maxResultCount=10}// using pagination object (Preferred)placesClient.searchByText(searchByTextRequest).addOnSuccessListener{response:SearchByTextResponse->valplaces=response.placesvalpagination=response.paginationif(pagination.hasNextPage()){pagination.setPageSize(20)pagination.fetchNextPage().addOnSuccessListener{nextPageResponse->valnextPagePlaces=nextPageResponse.getPlaces()}.addOnFailureListener{// Handle error with given status code}}}.addOnFailureListener{// TODO: Handle error with given status code.exception->{exception.printStackTrace();}}

Java

SearchByTextRequestsearchByTextRequest=SearchByTextRequest.builder("restaurants",Arrays.asList(Place.Field.NAME)).setMaxResultCount(10).build();// using pagination object (Preferred)placesClient.searchByText(searchByTextRequest).addOnSuccessListener((response)->{List<Place>places=response.getPlaces();Log.i(TAG,"Places result: "+places);Paginationpagination=response.getPagination();if(pagination.hasNextPage()){pagination.setPageSize(20);// change the page size from 10 to 20pagination.fetchNextPage().addOnSuccessListener((nextPageResponse)->{List<Place>nextPagePlaces=nextPageResponse.getPlaces();Log.i(TAG,"Next page places result: "+nextPagePlaces);});}}).addOnFailureListener((exception)->{if(exceptioninstanceofApiException){// Handle error with given status code}});

Required parameters

The required parameters forSearchByTextRequestare:

  • Field list

    Specify which place data fields to return. Pass a list ofPlace.Field values specifying the data fields to return. There is no default list of returned fields in the response.

    Field lists are a good design practice to ensure that you don't request unnecessary data, which helps to avoid unnecessary processing time and billing charges.

    Specify one or more of the following fields:

    • The following fields trigger theText Search Essentials ID Only SKU:

      Place.Field.DISPLAY_NAME*
          * Use instead ofPlace.Field.NAME (deprecated in version 4.0).
      Place.Field.ID
      Place.Field.RESOURCE_NAME*
          * Contains the place resource name in the form:places/PLACE_ID.
           UseDISPLAY_NAME to access the text name of the place.
    • The following fields trigger theText Search Pro SKU:

      Place.Field.ACCESSIBILITY_OPTIONS*
          Use instead ofPlace.Field.WHEELCHAIR_ACCESSIBLE_ENTRANCE (deprecated).
      Place.Field.ADDRESS_COMPONENTS
      Place.Field.ADR_FORMAT_ADDRESS
      Place.Field.BUSINESS_STATUS
      Place.Field.FORMATTED_ADDRESS*
          Use instead ofPlace.Field.ADDRESS (deprecated).
      Place.Field.GOOGLE_MAPS_URI
      Place.Field.ICON_BACKGROUND_COLOR
      Place.Field.ICON_MASK_URL *
          Use instead ofPlace.Field.ICON_URL (deprecated).
      Place.Field.LOCATION*
          Use instead ofPlace.Field.LAT_LNG (deprecated).
      Place.Field.PHOTO_METADATAS
      Place.Field.PLUS_CODE
      Place.Field.PRIMARY_TYPE
      Place.Field.PRIMARY_TYPE_DISPLAY_NAME
      Place.Field.SHORT_FORMATTED_ADDRESS
      Place.Field.SUB_DESTINATIONS
      Place.Field.TYPES
      Place.Field.UTC_OFFSET
      Place.Field.VIEWPORT
    • The following fields trigger theText Search Enterprise SKU:

      Place.Field.CURRENT_OPENING_HOURS
      Place.Field.CURRENT_SECONDARY_OPENING_HOURS
      Place.Field.INTERNATIONAL_PHONE_NUMBER*
          * Use instead ofPlace.Field.PHONE_NUMBER, which isdeprecated.
      Place.Field.NATIONAL_PHONE_NUMBER
      Place.Field.OPENING_HOURS
      Place.Field.PRICE_LEVEL
      Place.Field.RATING
      Place.Field.SECONDARY_OPENING_HOURS
      Place.Field.USER_RATING_COUNT*
          * Use instead ofPlace.Field.USER_RATINGS_TOTAL, which isdeprecated.
      Place.Field.WEBSITE_URI
    • The following fields trigger theText Search Enterprise Plus SKU:

      Place.Field.ALLOWS_DOGS
      Place.Field.CURBSIDE_PICKUP
      Place.Field.DELIVERY
      Place.Field.DINE_IN
      Place.Field.EDITORIAL_SUMMARY
      Place.Field.EV_CHARGE_OPTIONS
      Place.Field.FUEL_OPTIONS
      Place.Field.GOOD_FOR_CHILDREN
      Place.Field.GOOD_FOR_GROUPS
      Place.Field.GOOD_FOR_WATCHING_SPORTS
      Place.Field.LIVE_MUSIC
      Place.Field.MENU_FOR_CHILDREN
      Place.Field.OUTDOOR_SEATING
      Place.Field.PARKING_OPTIONS
      Place.Field.PAYMENT_OPTIONS
      Place.Field.RESERVABLE
      Place.Field.RESTROOM
      Place.Field.REVIEWS
      Place.Field.SERVES_BEER
      Place.Field.SERVES_BREAKFAST
      Place.Field.SERVES_BRUNCH
      Place.Field.SERVES_COCKTAILS
      Place.Field.SERVES_COFFEE
      Place.Field.SERVES_DESSERT
      Place.Field.SERVES_DINNER
      Place.Field.SERVES_LUNCH
      Place.Field.SERVES_VEGETARIAN_FOOD
      Place.Field.SERVES_WINE
      Place.Field.TAKEOUT

    To set the field list parameter, call thesetPlaceFields() method when building theSearchByTextRequest object.

  • Text query

    The text string on which to search, for example: "restaurant", "123 Main Street", or "best place to visit in San Francisco". The API returns candidate matches based on this string and orders the results based on their perceived relevance.

    To set the text query parameter, call thesetTextQuery() method when building theSearchByTextRequest object.

    Note:For best results when searching on a phone number,include the country code followed by a space, and set theregionCode parameter to correspond to the country code.Phone number formats vary by country and the API attempts to return a result for thesedifferent formats.

Optional parameters

Use theSearchByTextRequestobject to specify the optional parameters for your request.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-11-21 UTC.