SearchEngine
public class SearchEngine : SearchInterface
extension SearchEngine: NativeBase
extension SearchEngine: Hashable
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 SearchCompletionHandler and the
other uses a SearchExtendedCompletionHandler: 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.
-
Creates a new instance of this class.
Throws
InstantiationErrorIndicates what went wrong when the instantiation was attempted.Declaration
Swift
public init() throws -
Creates a new instance of this class.
Throws
InstantiationErrorIndicates what went wrong when the instantiation was attempted.Declaration
Swift
public init(_ sdkEngine: SDKNativeEngine) throwsParameters
sdkEngineInstance of an existing SDKEngine.
-
Performs an asynchronous text query search for
Placeinstances within a givenTextQuery.Area. The returned places are sorted by relevance.Declaration
Swift
@discardableResult public func searchByText(_ query: TextQuery, options: SearchOptions, completion: @escaping SearchCompletionHandler) -> TaskHandleParameters
queryDesired free-form text query to search.
optionsSearch options.
completionCallback which receives the result on the main thread.
Return Value
Handle that will be used to manipulate the execution of the task.
-
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.Declaration
Swift
@discardableResult public func searchByAddress(_ query: AddressQuery, options: SearchOptions, completion: @escaping SearchCompletionHandler) -> TaskHandleParameters
queryDesired free-form address query text to search.
optionsSearch options.
completionCallback which receives the result on the main thread.
Return Value
Handle that will be used to manipulate the execution of the task.
-
Performs an asynchronous category search for
Placeinstances. A list containing at least onePlaceCategorymust be provided as part of thesearchByCategory(...).query.Declaration
Swift
@discardableResult public func searchByCategory(_ query: CategoryQuery, options: SearchOptions, completion: @escaping SearchCompletionHandler) -> TaskHandleParameters
queryQuery with list of desired categories.
optionsSearch options.
completionCallback which receives the result on the main thread.
Return Value
Handle that will be used to manipulate the execution of the task.
-
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.Declaration
Swift
@discardableResult public func searchByCoordinates(_ coordinates: GeoCoordinates, options: SearchOptions, completion: @escaping SearchCompletionHandler) -> TaskHandleParameters
coordinatesThe coordinates where to search.
optionsSearch options.
completionCallback which receives result on the main thread.
Return Value
Handle that will be used to manipulate execution of the task.
-
Performs an asynchronous search for a
Placebased on its ID andLanguageCode.Declaration
Swift
@discardableResult public func searchByPlaceId(_ query: PlaceIdQuery, languageCode: LanguageCode?, completion: @escaping PlaceIdSearchCompletionHandler) -> TaskHandleParameters
queryThe id of place to search.
languageCodeThe preferred language for the search results. When unset or unsupported language is chosen, results will be returned in their local language.
completionCallback which receives the result on the main thread.
Return Value
Handle that will be used to manipulate the execution of the task.
-
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.noResultsFounderror is reported. When that happens, you may try to obtain the POI from the offline map by callingOfflineSearchEngine.searchByPickedPlace. Note that not all editions include theOfflineSearchEngine.Declaration
Swift
@discardableResult public func searchByPickedPlace(_ pickedPlace: PickedPlace, languageCode: LanguageCode?, completion: @escaping PlaceIdSearchCompletionHandler) -> TaskHandleParameters
pickedPlaceThe content picked from map.
languageCodeThe preferred language for the search result. When unset or unsupported language is chosen, result will be returned in the local language.
completionCallback which receives the result on the main thread.
Return Value
Handle that will be used to manipulate the execution of the task.
-
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.Declaration
Swift
@discardableResult public func suggestByText(_ query: TextQuery, options: SearchOptions, completion: @escaping SuggestCompletionHandler) -> TaskHandleParameters
queryDesired text query to search.
optionsSearch options.
completionCallback which receives the result on the main thread.
Return Value
Handle that will be used to manipulate the execution of the task.
-
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.Declaration
Swift
@discardableResult public func search(textQuery query: TextQuery, options: SearchOptions, completion: @escaping SearchExtendedCompletionHandler) -> TaskHandleParameters
queryDesired free-form text query to search.
optionsSearch options.
completionCallback which receives the result on the main thread.
Return Value
Handle that will be used to manipulate the execution of the task.
-
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.Declaration
Swift
@discardableResult public func search(addressQuery query: AddressQuery, options: SearchOptions, completion: @escaping SearchExtendedCompletionHandler) -> TaskHandleParameters
queryDesired free-form address query text to search.
optionsSearch options.
completionCallback which receives the result on the main thread.
Return Value
Handle that will be used to manipulate the execution of the task.
-
Performs an asynchronous request to search for a
Placebased on its ID andLanguageCode.Declaration
Swift
@discardableResult public func search(placeIdQuery query: PlaceIdQuery, languageCode: LanguageCode?, completion: @escaping PlaceIdSearchExtendedCompletionHandler) -> TaskHandleParameters
queryThe id of place to search.
languageCodeThe preferred language for the search results. When unset or unsupported language is chosen, results will be returned in their local language.
completionCallback which receives the result on the main thread.
Return Value
Handle that will be used to manipulate the execution of the task.
-
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.Declaration
Swift
@discardableResult public func search(coordinates: GeoCoordinates, options: SearchOptions, completion: @escaping SearchExtendedCompletionHandler) -> TaskHandleParameters
coordinatesThe coordinates where to search.
optionsSearch options.
completionCallback which receives result on the main thread.
Return Value
Handle that will be used to manipulate execution of the task.
-
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.Declaration
Swift
@discardableResult public func search(circle: GeoCircle, options: SearchOptions, completion: @escaping SearchCompletionHandler) -> TaskHandleParameters
circleThe coordinates where to search and radius of the circular spatial filter. Passed in form of
GeoCircle.optionsSearch options.
completionCallback which receives result on the main thread.
Return Value
Handle that will be used to manipulate execution of the task.
-
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.Declaration
Swift
@discardableResult public func search(circle: GeoCircle, options: SearchOptions, completion: @escaping SearchExtendedCompletionHandler) -> TaskHandleParameters
circleThe coordinates where to search and radius of the circular spatial filter. Passed in form of
GeoCircle.optionsSearch options.
completionCallback which receives result on the main thread.
Return Value
Handle that will be used to manipulate execution of the task.
-
Performs an asynchronous request by using the given href. The href value can be obtained from
Suggestionobjects, which are the result of successful call toSearchEngine.suggest(...). Currently supports only /v1/discover path. Provides candidate places sorted by relevance.Declaration
Swift
@discardableResult public func sendRequest(href: String, completion: @escaping SearchCompletionHandler) -> TaskHandleParameters
hrefThe direct link.
completionCallback which receives result on the main thread.
Return Value
Handle that will be used to manipulate execution of the task.
-
Performs an asynchronous request by using the given href. The href value can be obtained from
Suggestionobjects, which are the result of successful call toSearchEngine.suggest(...). Currently supports only /v1/discover path. Provides candidate places sorted by relevance.Declaration
Swift
@discardableResult public func sendRequest(href: String, completion: @escaping SearchExtendedCompletionHandler) -> TaskHandleParameters
hrefThe direct link.
completionCallback which receives result on the main thread.
Return Value
Handle that will be used to manipulate execution of the task.
-
Performs an asynchronous request to do a category search for
Placeinstances. A list containing at least onePlaceCategorymust be provided as part of theSearchEngine.search(CategoryQuery, SearchOptions, SearchExtendedCompletionHandler).query.Declaration
Swift
@discardableResult public func search(categoryQuery query: CategoryQuery, options: SearchOptions, completion: @escaping SearchExtendedCompletionHandler) -> TaskHandleParameters
queryQuery with list of desired categories.
optionsSearch options.
completionCallback which receives the result on the main thread.
Return Value
Handle that will be used to manipulate the execution of the task.
-
Performs an asynchronous request to suggest places for text queries and returns candidate suggestions sorted by relevance.
Declaration
Swift
@discardableResult public func suggest(textQuery query: TextQuery, options: SearchOptions, completion: @escaping SuggestExtendedCompletionHandler) -> TaskHandleParameters
queryDesired text query to search.
optionsSearch options.
completionCallback which receives the result on the main thread.
Return Value
Handle that will be used to manipulate the execution of the task.
-
Sets a custom option for search backend queries. This allows more control over the behavior of the search algorithm. Name has the format
. , 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 ™. 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 =
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.invalidCustomOptionFormatwill 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.badRequest. 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.
Declaration
Swift
public func setCustomOption(name: String, value: String) -> SearchError?Parameters
nameOption name in the format
. , for example “discover.show”. valueOption value.
Return Value
Error in case when setting the option fails.