Stay organized with collections Save and categorize content based on your preferences.
Text Search (New) returns information about a set of places based on a string (for example, "pizza in New York" or "shoe stores near Ottawa" or "123 Main Street"). The service responds with a list of places matching the text string and any location bias that has been set.
In addition to required parameters, Text Search (New) supports refining queries using optional parameters for better results.
Text Search (New) is similar to Nearby Search (New). The main difference between the two is that Text Search (New) lets you specify an arbitrary search string while Nearby Search (New) requires a specific area in which to search.
Note: Text Search (New) is available in Places SDK for Android version 3.3.0 and later. For more information, see Choose your SDK version. For more information about using the Kotlin APIs added in version 4.0.0, see the Reference Overview. Text Search requests Note: Text Search is part of Places SDK for Android (New) and is not available in Places SDK for Android.A Text Search request is in the form:
// Specify the list of fields to return. final List<Place.Field> placeFields = Arrays.asList(Place.Field.ID, Place.Field.DISPLAY_NAME); // Define latitude and longitude coordinates of the search area. LatLng southWest = new LatLng(37.38816277477739, -122.08813770258874); LatLng northEast = new LatLng(37.39580487866437, -122.07702325966572); // Use the builder to create a SearchByTextRequest object. final SearchByTextRequest searchByTextRequest = 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:
Set the field list to include only Place.Field.ID
and Place.Field.DISPLAY_NAME
. That means the Place
objects in the response that represent each matching place only contain those two fields.
Use SearchByTextRequest.Builder
to create a SearchByTextRequest
object that defines the search.
Set the text query string to "Spicy Vegetarian Food".
Set the maximum number of result places to 10. The default and the maximum is 20.
Restrict the search area to the rectangle defined by latitude and longitude coordinates. No matches outside of this area are returned.
Add an OnSuccessListener
and get the matching places from the SearchByTextResponse
object.
PlacesClient
, see Initialize the Places API client.
You can use a CancellationToken to 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 request will be cancelled, and you may still be charged for the request even if no response is returned.
The SearchByTextResponse
class represents the response from a search request. A SearchByTextResponse
object contains:
A list of Place
objects that represent all matching places, with one Place
object per matching place.
Each Place
object only contains the fields defined by the field list passed in the request.
For example, in the request you defined a field list as:
// Specify the list of fields to return. final List<Place.Field> placeFields = Arrays.asList(Place.Field.ID, Place.Field.DISPLAY_NAME);
This field list means that each Place
object in the response contains only the place ID and name of each matching place. You can then use the Place.getId()
and Place.getName()
methods to access these fields in each Place
object.
For more examples of accessing data in a Place
object, see Access Place object data fields
The required parameters for SearchByTextRequest
are:
Specify which place data fields to return. Pass a list of Place.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 the Text Search Essentials ID Only SKU:
Place.Field.DISPLAY_NAME
* Place.Field.NAME
(deprecated in version 4.0).Place.Field.ID
Place.Field.RESOURCE_NAME
*places/PLACE_ID
. DISPLAY_NAME
to access the text name of the place.The following fields trigger the Text Search Pro SKU:
Place.Field.ACCESSIBILITY_OPTIONS
*Place.Field.WHEELCHAIR_ACCESSIBLE_ENTRANCE
(deprecated).Place.Field.ADDRESS_COMPONENTS
Place.Field.ADR_FORMAT_ADDRESS
Place.Field.BUSINESS_STATUS
Place.Field.FORMATTED_ADDRESS
* Place.Field.ADDRESS
(deprecated).Place.Field.GOOGLE_MAPS_URI
Place.Field.ICON_BACKGROUND_COLOR
Place.Field.ICON_MASK_URL
* Place.Field.ICON_URL
(deprecated).Place.Field.LOCATION
*Place.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 the Text Search Enterprise SKU:
Place.Field.CURRENT_OPENING_HOURS
Place.Field.CURRENT_SECONDARY_OPENING_HOURS
Place.Field.INTERNATIONAL_PHONE_NUMBER
* Place.Field.PHONE_NUMBER
, which is deprecated.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
* Place.Field.USER_RATINGS_TOTAL
, which is deprecated.Place.Field.WEBSITE_URI
The following fields trigger the Text 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 the setPlaceFields()
method when building the SearchByTextRequest
object.
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 the setTextQuery()
method when building the SearchByTextRequest
object.
regionCode
parameter to correspond to the country code. Phone number formats vary by country and the API attempts to return a result for these different formats.Use the SearchByTextRequest
object to specify the optional parameters for your request.
Restricts the results to places matching the specified type defined by Table A. Only one type may be specified. For example:
setIncludedType("bar")
setIncludedType("pharmacy")
To set the included type parameter, call the setIncludedType()
method when building the SearchByTextRequest
object.
Specifies an area to search. This location serves as a bias which means results around the specified location can be returned, including results outside the specified area.
You can specify location restriction or location bias, but not both. Think of location restriction as specifying the region which the results must be within, and location bias as specifying the region that the results will likely be within or near — keeping in mind that when using location bias, results can still be outside of the specified area.
Note: If you omit both location bias and location restriction, then the API uses IP biasing by default. With IP biasing, the API uses the IP address of the device to bias the results. Note: ThelocationBias
parameter can be overridden if the textQuery
contains an explicit location such as Market in Barcelona
. In this case, locationBias
is ignored.
Specify the region as a rectangular Viewport or as a circle.
A circle is defined by center point and radius in meters. The radius must be between 0.0 and 50000.0, inclusive. For example:
// Define latitude and longitude coordinates of the center of the search area. LatLng searchCenter = new LatLng(37.38816277477739, -122.08813770258874); // Use the builder to create a SearchByTextRequest object. // Set the radius of the search area to 500.0 meters. final SearchByTextRequest searchByTextRequest = SearchByTextRequest.builder("Spicy Vegetarian Food", placeFields) .setMaxResultCount(10) .setLocationBias(CircularBounds.newInstance(searchCenter, 500.0)).build();
A rectangle is a latitude-longitude viewport, represented as two diagonally opposite low and high points. The low point marks the southwest corner of the rectangle, and the high point represents the northeast corner of the rectangle.
A viewport is considered a closed region, meaning it includes its boundary. The latitude bounds must range between -90 to 90 degrees inclusive, and the longitude bounds must range between -180 to 180 degrees inclusive:
low
= high
, the viewport consists of that single point.low.longitude
> high.longitude
, the longitude range is inverted (the viewport crosses the 180 degree longitude line).low.longitude
= -180 degrees and high.longitude
= 180 degrees, the viewport includes all longitudes.low.longitude
= 180 degrees and high.longitude
= -180 degrees, the longitude range is empty.low.latitude
> high.latitude
, the latitude range is empty.Both low and high must be populated, and the represented box cannot be empty. An empty viewport results in an error.
For example, of a rectangular viewport see Text Search requests.
To set the location bias parameter, call the setLocationBias()
method when building the SearchByTextRequest
object.
Specifies an area to search. Results outside the specified area are not returned. Specify the region as a rectangular Viewport. See the description of Location bias for information on defining the Viewport.
You can specify location restriction or location bias, but not both. Think of location restriction as specifying the region which the results must be within, and location bias as specifying the region that the results must be near but can be outside the area.
Note: If you omit both location bias and location restriction, then the API uses IP biasing by default. With IP biasing, the API uses the IP address of the device to bias the results.To set the location restriction parameter, call the setLocationRestriction()
method when building the SearchByTextRequest
object.
Specifies the maximum number of place results to return. Must be between 1 and 20 (default) inclusive.
To set the maximum result count parameter, call the setMaxResultCount()
method when building the SearchByTextRequest
object.
Restricts results to only those whose average user rating is greater than or equal to this limit. Values must be between 0.0 and 5.0 (inclusive) in increments of 0.5. For example: 0, 0.5, 1.0, ... , 5.0 inclusive. Values are rounded up to the nearest 0.5. For example, a value of 0.6 eliminates all results with a rating less than 1.0.
To set the minimum rating parameter, call the setMinRating()
method when building the SearchByTextRequest
object.
If true
, return only those places that are open for business at the time the query is sent. If false
, return all businesses regardless of open status. Places that don't specify opening hours in the Google Places database are returned if you set this parameter to false
.
To set the open now parameter, call the setOpenNow()
method when building the SearchByTextRequest
object.
By default, results include places that provide services at all price levels. To restrict results to only include places at particular price levels, you can pass a list of integer values that correspond to the price levels for the places that you want to return:
1
- Place provides inexpensive services.2
- Place provides moderately priced services.3
- Place provides expensive services.4
- Place provides very expensive services.0
, which indicates that the place provides free services, may be included in a response, but cannot be used as a filter value in a request.
To set the price levels parameter, call the setPriceLevels()
method when building the SearchByTextRequest
object.
Specifies how the results are ranked in the response based on the type of query:
SearchByTextRequest.RankPreference.RELEVANCE
(rank results by search relevance) is the default. You can set rank preference to SearchByTextRequest.RankPreference.RELEVANCE
or SearchByTextRequest.RankPreference.DISTANCE
(rank results by distance).To set the rank preference parameter, call the setRankPreference()
method when building the SearchByTextRequest
object.
The region code used to format the response, specified as a two-character CLDR code value. This parameter can also have a bias effect on the search results. There is no default value.
If the country name of the address field in the response matches the region code, the country code is omitted from address.
Most CLDR codes are identical to ISO 3166-1 codes, with some notable exceptions. For example, the United Kingdom's ccTLD is "uk" (.co.uk) while its ISO 3166-1 code is "gb" (technically for the entity of "The United Kingdom of Great Britain and Northern Ireland"). The parameter can affect results based on applicable law.
To set the region code parameter, call the setRegionCode()
method when building the SearchByTextRequest
object.
Used with the include type parameter. When set to true
, only places that match the specified types specified by include type are returned. When false
, the default, the response can contain places that don't match the specified types.
To set the strict type filtering parameter, call the setStrictTypeFiltering()
method when building the SearchByTextRequest
object.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-14 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["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."]]],["Text Search retrieves place information via a text string, supporting various queries like business names, addresses, and phone numbers. It's available on Android, iOS, JavaScript, and Web Service. Searches can be refined with location bias or restriction, maximum result count, minimum rating, open now status, price levels, rank preference, and region codes. Android implementation uses `SearchByTextRequest` and `SearchByTextResponse` within the Places SDK for Android (New), offering cancellation options. IP biasing is the default if location is not set.\n"]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4