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

    InstantiationError Indicates what went wrong when the instantiation was attempted.

    Declaration

    Swift

    public init() throws
  • Creates a new instance of this class.

    Throws

    InstantiationError Indicates what went wrong when the instantiation was attempted.

    Declaration

    Swift

    public init(_ sdkEngine: SDKNativeEngine) throws

    Parameters

    sdkEngine

    Instance of an existing SDKEngine.

  • Performs an asynchronous text query search for Place instances within a given TextQuery.Area. The returned places are sorted by relevance.

    Declaration

    Swift

    @discardableResult
    public func searchByText(_ query: TextQuery, options: SearchOptions, completion: @escaping SearchCompletionHandler) -> TaskHandle

    Parameters

    query

    Desired free-form text query to search.

    options

    Search options.

    completion

    Callback 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 Place instances. 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 one Place result, 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) -> TaskHandle

    Parameters

    query

    Desired free-form address query text to search.

    options

    Search options.

    completion

    Callback 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 Place instances. A list containing at least one PlaceCategory must be provided as part of the searchByCategory(...).query.

    Declaration

    Swift

    @discardableResult
    public func searchByCategory(_ query: CategoryQuery, options: SearchOptions, completion: @escaping SearchCompletionHandler) -> TaskHandle

    Parameters

    query

    Query with list of desired categories.

    options

    Search options.

    completion

    Callback 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 Place instances based on the given geographic coordinates. This is the same search type as reverse geocoding, except that more data is returned than just the Address related to the given coordinates. Note that more than one Place can 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) -> TaskHandle

    Parameters

    coordinates

    The coordinates where to search.

    options

    Search options.

    completion

    Callback 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 Place based on its ID and LanguageCode.

    Declaration

    Swift

    @discardableResult
    public func searchByPlaceId(_ query: PlaceIdQuery, languageCode: LanguageCode?, completion: @escaping PlaceIdSearchCompletionHandler) -> TaskHandle

    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.

    completion

    Callback 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 Place based on the content found in PickedPlace. If PickedPlace data is obtained from the offline map, it may happen that the newer version that is used by the online service represented by SearchEngine no longer contains the related POI. In that case, SearchError.noResultsFound error is reported. When that happens, you may try to obtain the POI from the offline map by calling OfflineSearchEngine.searchByPickedPlace. Note that not all editions include the OfflineSearchEngine.

    Declaration

    Swift

    @discardableResult
    public func searchByPickedPlace(_ pickedPlace: PickedPlace, languageCode: LanguageCode?, completion: @escaping PlaceIdSearchCompletionHandler) -> TaskHandle

    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.

    completion

    Callback 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 OfflineSearchEngine includes as many details as are available, SearchEngine includes only the information that is relevant for autosuggest use cases. Complete details can be obtained by searching with PlaceIdQuery.

    Declaration

    Swift

    @discardableResult
    public func suggestByText(_ query: TextQuery, options: SearchOptions, completion: @escaping SuggestCompletionHandler) -> TaskHandle

    Parameters

    query

    Desired text query to search.

    options

    Search options.

    completion

    Callback 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 Place instances. Optionally, search along a polyline, such as a route, by specifying a GeoCorridor. Provides candidate places sorted by relevance.

    Declaration

    Swift

    @discardableResult
    public func search(textQuery query: TextQuery, options: SearchOptions, completion: @escaping SearchExtendedCompletionHandler) -> TaskHandle

    Parameters

    query

    Desired free-form text query to search.

    options

    Search options.

    completion

    Callback 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 Place result, 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) -> TaskHandle

    Parameters

    query

    Desired free-form address query text to search.

    options

    Search options.

    completion

    Callback 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 Place based on its ID and LanguageCode.

    Declaration

    Swift

    @discardableResult
    public func search(placeIdQuery query: PlaceIdQuery, languageCode: LanguageCode?, completion: @escaping PlaceIdSearchExtendedCompletionHandler) -> TaskHandle

    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.

    completion

    Callback 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 Address that belongs to given coordinates. Note that coordinates can belong to more than one Place result. Provides candidate places sorted by relevance.

    Declaration

    Swift

    @discardableResult
    public func search(coordinates: GeoCoordinates, options: SearchOptions, completion: @escaping SearchExtendedCompletionHandler) -> TaskHandle

    Parameters

    coordinates

    The coordinates where to search.

    options

    Search options.

    completion

    Callback 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 Address that belongs to given coordinates. Note that coordinates can belong to more than one Place result. 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) -> TaskHandle

    Parameters

    circle

    The coordinates where to search and radius of the circular spatial filter. Passed in form of GeoCircle.

    options

    Search options.

    completion

    Callback 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 Address that belongs to given coordinates. Note that coordinates can belong to more than one Place result. 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) -> TaskHandle

    Parameters

    circle

    The coordinates where to search and radius of the circular spatial filter. Passed in form of GeoCircle.

    options

    Search options.

    completion

    Callback 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 Suggestion objects, which are the result of successful call to SearchEngine.suggest(...). Currently supports only /v1/discover path. Provides candidate places sorted by relevance.

    Declaration

    Swift

    @discardableResult
    public func sendRequest(href: String, completion: @escaping SearchCompletionHandler) -> TaskHandle

    Parameters

    href

    The direct link.

    completion

    Callback 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 Suggestion objects, which are the result of successful call to SearchEngine.suggest(...). Currently supports only /v1/discover path. Provides candidate places sorted by relevance.

    Declaration

    Swift

    @discardableResult
    public func sendRequest(href: String, completion: @escaping SearchExtendedCompletionHandler) -> TaskHandle

    Parameters

    href

    The direct link.

    completion

    Callback 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 Place instances. A list containing at least one PlaceCategory must be provided as part of the SearchEngine.search(CategoryQuery, SearchOptions, SearchExtendedCompletionHandler).query.

    Declaration

    Swift

    @discardableResult
    public func search(categoryQuery query: CategoryQuery, options: SearchOptions, completion: @escaping SearchExtendedCompletionHandler) -> TaskHandle

    Parameters

    query

    Query with list of desired categories.

    options

    Search options.

    completion

    Callback 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) -> TaskHandle

    Parameters

    query

    Desired text query to search.

    options

    Search options.

    completion

    Callback 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.forbidden will 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.forbidden will 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.invalidCustomOptionFormat will 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 a GeoCorridor generates an error SearchError.badRequest. Note: It is recommended to use SearchOptions.distributedResults instead. 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

    name

    Option name in the format ., for example “discover.show”.

    value

    Option value.

    Return Value

    Error in case when setting the option fails.