Class SearchEngine

java.lang.Object
com.here.NativeBase
com.here.sdk.search.SearchEngine
All Implemented Interfaces:
SearchInterface

public final class SearchEngine extends NativeBase implements 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 Details

  • 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 Place instances. Optionally, search along a polyline, such as a route, by specifying a GeoCorridor. 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 Place result, 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 Place based on its ID and LanguageCode.

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

      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 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.

      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

      @NonNull public TaskHandle sendRequest(@NonNull String href, @NonNull SearchCallback callback)

      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 suggest(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 Suggestion objects, which are the result of successful call to suggest(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 Place instances. A list containing at least one PlaceCategory must be provided as part of the query.

      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

      @Nullable public SearchError setCustomOption(@NonNull String name, @NonNull String value)

      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.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 (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_FORMAT 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.BAD_REQUEST. 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.
      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 Place instances within a given TextQuery.Area. The returned places are sorted by relevance.

      Specified by:
      searchByText in interface SearchInterface
      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 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.

      Specified by:
      searchByAddress in interface SearchInterface
      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 Place instances. A list containing at least one PlaceCategory must be provided as part of the query.

      Specified by:
      searchByCategory in interface SearchInterface
      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 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.

      Specified by:
      searchByCoordinates in interface SearchInterface
      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 Place based on its ID and LanguageCode.

      Specified by:
      searchByPlaceId in interface SearchInterface
      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 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.NO_RESULTS_FOUND error is reported. When that happens, you may try to obtain the POI from the offline map by calling OfflineSearchEngine.searchByPickedPlace, only available for the Navigate license.

      Specified by:
      searchByPickedPlace in interface SearchInterface
      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 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.

      Specified by:
      suggestByText in interface SearchInterface
      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.