SearchEngine (API Reference)
Class SearchEngine
- All Implemented Interfaces:
SearchInterface
The SearchEngine API unlocks the search, geocoding and suggesting capabilities of HERE services to provide developers with unmatched flexibility to create differentiating location-enabled applications. It enables to search for HERE points of interests, forward and reverse geocode addresses and geographic coordinates from the HERE map and search for suggested addresses or place candidates based on incomplete or misspelled queries.
It also allows to search along a given GeoPolyline set inside a GeoCorridor
as part of a TextQuery.
The SearchEngine API requires an online connection to execute the requests.
Note: All methods are provided in two flavors. One uses a SearchCallback and the
other uses a SearchCallbackExtended: The later adds a ResponseDetails result type
that provides the requestId of a search request and a correlationId to identify multiple,
related queries. This may be useful for debug purposes.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of this class.SearchEngine(SDKNativeEngine sdkEngine) Creates a new instance of this class. -
Method Summary
Modifier and TypeMethodDescriptionsearch(GeoCircle circle, SearchOptions options, SearchCallback callback) Performs an asynchronous request to search for places based on given circular spatial filter.search(GeoCircle circle, SearchOptions options, SearchCallbackExtended callback) Performs an asynchronous request to search for places based on given circular spatial filter.search(GeoCoordinates coordinates, SearchOptions options, SearchCallbackExtended callback) Performs an asynchronous request to search for places based on given geographic coordinates.search(AddressQuery query, SearchOptions options, SearchCallbackExtended callback) Performs an asynchronous request to search for places based on a given address.search(CategoryQuery query, SearchOptions options, SearchCallbackExtended callback) Performs an asynchronous request to do a category search forPlaceinstances.search(PlaceIdQuery query, LanguageCode languageCode, PlaceIdSearchCallbackExtended callback) Performs an asynchronous request to search for aPlacebased on its ID andLanguageCode.search(TextQuery query, SearchOptions options, SearchCallbackExtended callback) Performs an asynchronous request to do a text query search forPlaceinstances.searchByAddress(AddressQuery query, SearchOptions options, SearchCallback callback) Performs an asynchronous address query search forPlaceinstances.searchByCategory(CategoryQuery query, SearchOptions options, SearchCallback callback) Performs an asynchronous category search forPlaceinstances.searchByCoordinates(GeoCoordinates coordinates, SearchOptions options, SearchCallback callback) Performs an asynchronous search forPlaceinstances based on the given geographic coordinates.searchByPickedPlace(PickedPlace pickedPlace, LanguageCode languageCode, PlaceIdSearchCallback callback) Performs an asynchronous search for aPlacebased on the content found inPickedPlace.searchByPlaceId(PlaceIdQuery query, LanguageCode languageCode, PlaceIdSearchCallback callback) Performs an asynchronous search for aPlacebased on its ID andLanguageCode.searchByText(TextQuery query, SearchOptions options, SearchCallback callback) Performs an asynchronous text query search forPlaceinstances within a givenTextQuery.Area.sendRequest(String href, SearchCallback callback) Performs an asynchronous request by using the given href.sendRequest(String href, SearchCallbackExtended callback) Performs an asynchronous request by using the given href.setCustomOption(String name, String value) Sets a custom option for search backend queries.suggest(TextQuery query, SearchOptions options, SuggestCallbackExtended callback) Performs an asynchronous request to suggest places for text queries and returns candidate suggestions sorted by relevance.suggestByText(TextQuery query, SearchOptions options, SuggestCallback callback) Performs an asynchronous request to suggest places for text queries and returns suggestions sorted by relevance.
-
Constructor Details
-
SearchEngine
Creates a new instance of this class.
- Throws:
InstantiationErrorException-Indicates what went wrong when the instantiation was attempted.
-
SearchEngine
Creates a new instance of this class.
- Parameters:
sdkEngine-Instance of an existing SDKEngine.
- Throws:
InstantiationErrorException-Indicates what went wrong when the instantiation was attempted.
-
-
Method Details
-
search
@NonNull public TaskHandle search(@NonNull TextQuery query, @NonNull SearchOptions options, @NonNull SearchCallbackExtended callback) Performs an asynchronous request to do a text query search for
Placeinstances. Optionally, search along a polyline, such as a route, by specifying aGeoCorridor. Provides candidate places sorted by relevance.- Parameters:
query-Desired free-form text query to search.
options-Search options.
callback-Callback which receives the result on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
search
@NonNull public TaskHandle search(@NonNull AddressQuery query, @NonNull SearchOptions options, @NonNull SearchCallbackExtended callback) Performs an asynchronous request to search for places based on a given address. This is the same process as forward geocoding, except that more data is returned than just the geographic coordinates of a given address. Note that an address can belong to more than one
Placeresult, although all found places will share the same geographic coordinates. Provides candidate places sorted by relevance.- Parameters:
query-Desired free-form address query text to search.
options-Search options.
callback-Callback which receives the result on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
search
@NonNull public TaskHandle search(@NonNull PlaceIdQuery query, @Nullable LanguageCode languageCode, @NonNull PlaceIdSearchCallbackExtended callback) Performs an asynchronous request to search for a
Placebased on its ID andLanguageCode.- Parameters:
query-The id of place to search.
languageCode-The preferred language for the search results. When unset or unsupported language is chosen, results will be returned in their local language.
callback-Callback which receives the result on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
search
@NonNull public TaskHandle search(@NonNull GeoCoordinates coordinates, @NonNull SearchOptions options, @NonNull SearchCallbackExtended callback) Performs an asynchronous request to search for places based on given geographic coordinates. This is the same process as reverse geocoding, except that more data is returned than just the
Addressthat belongs to given coordinates. Note that coordinates can belong to more than onePlaceresult. Provides candidate places sorted by relevance.- Parameters:
coordinates-The coordinates where to search.
options-Search options.
callback-Callback which receives result on the main thread.
- Returns:
Handle that will be used to manipulate execution of the task.
-
search
@NonNull public TaskHandle search(@NonNull GeoCircle circle, @NonNull SearchOptions options, @NonNull SearchCallback callback) Performs an asynchronous request to search for places based on given circular spatial filter. This is the same process as reverse geocoding, except that more data is returned than just the
Addressthat belongs to given coordinates. Note that coordinates can belong to more than onePlaceresult. Provides candidate places sorted by relevance and located inside the radius of filter.- Parameters:
circle-The coordinates where to search and radius of the circular spatial filter. Passed in form of
GeoCircle.options-Search options.
callback-Callback which receives result on the main thread.
- Returns:
Handle that will be used to manipulate execution of the task.
-
search
@NonNull public TaskHandle search(@NonNull GeoCircle circle, @NonNull SearchOptions options, @NonNull SearchCallbackExtended callback) Performs an asynchronous request to search for places based on given circular spatial filter. This is the same process as reverse geocoding, except that more data is returned than just the
Addressthat belongs to given coordinates. Note that coordinates can belong to more than onePlaceresult. Provides candidate places sorted by relevance and located inside the radius of filter.- Parameters:
circle-The coordinates where to search and radius of the circular spatial filter. Passed in form of
GeoCircle.options-Search options.
callback-Callback which receives result on the main thread.
- Returns:
Handle that will be used to manipulate execution of the task.
-
sendRequest
Performs an asynchronous request by using the given href. The href value can be obtained from
Suggestionobjects, which are the result of successful call tosuggest(com.here.sdk.search.TextQuery, com.here.sdk.search.SearchOptions, com.here.sdk.search.SuggestCallbackExtended). Currently supports only /v1/discover path. Provides candidate places sorted by relevance.- Parameters:
href-The direct link.
callback-Callback which receives result on the main thread.
- Returns:
Handle that will be used to manipulate execution of the task.
-
sendRequest
@NonNull public TaskHandle sendRequest(@NonNull String href, @NonNull SearchCallbackExtended callback) Performs an asynchronous request by using the given href. The href value can be obtained from
Suggestionobjects, which are the result of successful call tosuggest(com.here.sdk.search.TextQuery, com.here.sdk.search.SearchOptions, com.here.sdk.search.SuggestCallbackExtended). Currently supports only /v1/discover path. Provides candidate places sorted by relevance.- Parameters:
href-The direct link.
callback-Callback which receives result on the main thread.
- Returns:
Handle that will be used to manipulate execution of the task.
-
search
@NonNull public TaskHandle search(@NonNull CategoryQuery query, @NonNull SearchOptions options, @NonNull SearchCallbackExtended callback) Performs an asynchronous request to do a category search for
Placeinstances. A list containing at least onePlaceCategorymust be provided as part of thequery.- Parameters:
query-Query with list of desired categories.
options-Search options.
callback-Callback which receives the result on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
suggest
@NonNull public TaskHandle suggest(@NonNull TextQuery query, @NonNull SearchOptions options, @NonNull SuggestCallbackExtended callback) Performs an asynchronous request to suggest places for text queries and returns candidate suggestions sorted by relevance.
- Parameters:
query-Desired text query to search.
options-Search options.
callback-Callback which receives the result on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
setCustomOption
Sets a custom option for search backend queries. This allows more control over the behavior of the search algorithm. Name has the format <endpoint_name>.<option_name>, for example "discover.show". Values can be combined for the same name by using a comma, for example "truck,fuel". The custom option is applied only for the endpoint that is specified as prefix in
name. Some of the supported name/value options are:- name = "revgeocode.with", value = "unnamedStreets" enables the retrieval of access points on unnamed streets.
- name = "lookup.show" or "discover.show" or "autosuggest.show" or "browse.show", value = "truck"
enables retreival of truck amenities.
Note: Only participants of the closed-alpha group can get access from HERE to use this feature,
otherwise, a
SearchError.FORBIDDENwill be propagated in callbacks. - name = "lookup.show" or "discover.show" or "autosuggest.show" or "browse.show", value = "fuel"
enables retreival of fuel station details.
Note: Only participants of the closed-alpha group can get access from HERE to use this feature,
otherwise, a
SearchError.FORBIDDENwill be propagated in callbacks. - name = "lookup.show" or "discover.show" or "browse.show", value = "ev" enables retreival of EV charging station details.
- name = "lookup.show" or "discover.show" or "browse.show", value = "eMobilityServiceProviders" enables retreival of e-Mobility Service Providers details.
- name = "lookup.show" or "discover.show" or "browse.show", value = "tripadvisor" adds images, ratings, and editorials from Tripadvisor (TM). Note: Only clients with a license with TripAdvisor for rich content will actually get it. If this licence is missing, TripAdvisor rich content will be missing, with no error reported. This content is only added to top 10 search results. If more results are returned, they will be missing rich TripAdvisor content.
- name = "lookup.datasets" or "discover.datasets" or "browse.datasets" or "autosuggest.datasets",
value = <your_dataset_hrn> enables ingesting and searching of private POIs.
Note: Only participants of the search customization can get access from HERE to use this feature,
otherwise, a
SearchError.INVALID_CUSTOM_OPTION_FORMATwill be propagated in callbacks. - name = "discover.ranking" or "browse.ranking", value = "excursionDistance"
enables balanced distribution of results for search in
GeoCorridor. Constraint: using this parameter when searching an area that is not aGeoCorridorgenerates an errorSearchError.BAD_REQUEST. Note: It is recommended to useSearchOptions.distributedResultsinstead. For a complete list of available endpoints, parameter names and their valid values, refer to HERE Geocoding & Search API v7. Note: It's easy to set a wrong option that makes queries invalid, so make sure you read and understand the backend documentation.
- Parameters:
name-Option name in the format <endpoint_name>.<option_name>, for example "discover.show".
value-Option value.
- Returns:
Error in case when setting the option fails.
-
searchByText
@NonNull public TaskHandle searchByText(@NonNull TextQuery query, @NonNull SearchOptions options, @NonNull SearchCallback callback) Performs an asynchronous text query search for
Placeinstances within a givenTextQuery.Area. The returned places are sorted by relevance.- Specified by:
searchByTextin interfaceSearchInterface- Parameters:
query-Desired free-form text query to search.
options-Search options.
callback-Callback which receives the result on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
searchByAddress
@NonNull public TaskHandle searchByAddress(@NonNull AddressQuery query, @NonNull SearchOptions options, @NonNull SearchCallback callback) Performs an asynchronous address query search for
Placeinstances. This is the same type of search as forward geocoding, except that more data is returned than just the geographic coordinates of a given address. Note that an address can belong to more than onePlaceresult, although all found places will share the same geographic coordinates. The returned places are sorted by relevance.- Specified by:
searchByAddressin interfaceSearchInterface- Parameters:
query-Desired free-form address query text to search.
options-Search options.
callback-Callback which receives the result on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
searchByCategory
@NonNull public TaskHandle searchByCategory(@NonNull CategoryQuery query, @NonNull SearchOptions options, @NonNull SearchCallback callback) Performs an asynchronous category search for
Placeinstances. A list containing at least onePlaceCategorymust be provided as part of thequery.- Specified by:
searchByCategoryin interfaceSearchInterface- Parameters:
query-Query with list of desired categories.
options-Search options.
callback-Callback which receives the result on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
searchByCoordinates
@NonNull public TaskHandle searchByCoordinates(@NonNull GeoCoordinates coordinates, @NonNull SearchOptions options, @NonNull SearchCallback callback) Performs an asynchronous search for
Placeinstances based on the given geographic coordinates. This is the same search type as reverse geocoding, except that more data is returned than just theAddressrelated to the given coordinates. Note that more than onePlacecan be related to the given coordinates. The returned places are sorted by relevance.- Specified by:
searchByCoordinatesin interfaceSearchInterface- Parameters:
coordinates-The coordinates where to search.
options-Search options.
callback-Callback which receives result on the main thread.
- Returns:
Handle that will be used to manipulate execution of the task.
-
searchByPlaceId
@NonNull public TaskHandle searchByPlaceId(@NonNull PlaceIdQuery query, @Nullable LanguageCode languageCode, @NonNull PlaceIdSearchCallback callback) Performs an asynchronous search for a
Placebased on its ID andLanguageCode.- Specified by:
searchByPlaceIdin interfaceSearchInterface- Parameters:
query-The id of place to search.
languageCode-The preferred language for the search results. When unset or unsupported language is chosen, results will be returned in their local language.
callback-Callback which receives the result on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
searchByPickedPlace
@NonNull public TaskHandle searchByPickedPlace(@NonNull PickedPlace pickedPlace, @Nullable LanguageCode languageCode, @NonNull PlaceIdSearchCallback callback) Performs an asynchronous search for a
Placebased on the content found inPickedPlace. IfPickedPlacedata is obtained from the offline map, it may happen that the newer version that is used by the online service represented bySearchEngineno longer contains the related POI. In that case,SearchError.NO_RESULTS_FOUNDerror is reported. When that happens, you may try to obtain the POI from the offline map by callingOfflineSearchEngine.searchByPickedPlace, only available for the Navigate license.- Specified by:
searchByPickedPlacein interfaceSearchInterface- Parameters:
pickedPlace-The content picked from map.
languageCode-The preferred language for the search result. When unset or unsupported language is chosen, result will be returned in the local language.
callback-Callback which receives the result on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
suggestByText
@NonNull public TaskHandle suggestByText(@NonNull TextQuery query, @NonNull SearchOptions options, @NonNull SuggestCallback callback) Performs an asynchronous request to suggest places for text queries and returns suggestions sorted by relevance.
Note that while
OfflineSearchEngineincludes as many details as are available,SearchEngineincludes only the information that is relevant for autosuggest use cases. Complete details can be obtained by searching withPlaceIdQuery.- Specified by:
suggestByTextin interfaceSearchInterface- Parameters:
query-Desired text query to search.
options-Search options.
callback-Callback which receives the result on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-