Class GLSearchRequest

java.lang.Object
globus.glsearch.GLSearchRequest

public final class GLSearchRequest extends Object
Request model for GLSearch. The same request runs against either transport: startOnline(ResultsCallback) queries the online search service (/v1/search, /v1/autocomplete); startOffline(ResultsCallback) queries the downloaded offline maps. Both apply the same ranking and display rules. The low-level GLSearch class (tag filters over offline data) is separate.

The request returns GLMapVectorObjectList with display data baked on each object: the primary name through the object's localized name, the second line as the search:secondaryText tag, and category/icon through GLSearch.GetSearchCategory(globus.glmap.GLMapVectorObject).

  • Field Details

    • type

      public final int type
      Request type: search or autocomplete.
    • text

      @NonNull public final String text
      User query text.
    • locales

      @Nullable public final String[] locales
      Ordered locale codes, for example {"be", "ru", "en", "native"}. The first entry is the preferred display language; every entry is used for matching. "native" requests the map object's native name. Null or empty uses native names only.
    • limit

      public final int limit
      Maximum number of results. Values less than 1 use server defaults.
    • center

      @Nullable public final MapGeoPoint center
      Search center used for result ranking. The center is not a strict geographic filter.
    • categories

      @Nullable public final String[] categories
      Optional GLSearch category identifiers, for example "cafe" or "restaurant".
  • Constructor Details

    • GLSearchRequest

      public GLSearchRequest(int type, @NonNull String text)
      Creates a search request from a type and text; center, limit, locales, and categories keep their defaults (no ranking center — global — and no category filter). Use the full constructor to customize.
      Parameters:
      type - request type: search or autocomplete
      text - user query text or autocomplete input
    • GLSearchRequest

      public GLSearchRequest(int type, @NonNull String text, @Nullable MapGeoPoint center, int limit, @Nullable String[] locales, @Nullable String[] categories)
      Creates a search request with a ranking center. The two nullable refinements (locales, categories) come last.
      Parameters:
      type - request type: search or autocomplete
      text - user query text or autocomplete input
      center - search center used for ranking nearby matches higher; null for a global request
      limit - maximum number of results; pass 0 to use server defaults
      locales - ordered locale codes; the first is the display language, all are used for matching; null for native names
      categories - GLSearch category identifiers; pass null for an unrestricted request
  • Method Details

    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • startOnline

      public long startOnline(@NonNull GLSearchRequest.ResultsCallback callback)
      Starts the request against the online search service.

      The callback may be invoked on a background thread (or synchronously, when the request completes without starting). If you update UI, post back to the main thread. The callback is invoked exactly once per start: a request with nothing to search (both text and categories are empty, or an autocomplete prefix is below the minimum length) completes with an empty result. Category-only requests are valid. A cancelled request completes with an ECANCELED error.

      Parameters:
      callback - callback that receives parsed vector objects or an error
      Returns:
      request ID that can be passed to cancel(long), or 0 if the request completed without starting
    • startOffline

      public long startOffline(@NonNull GLSearchRequest.ResultsCallback callback)
      Starts the same request against downloaded offline maps.

      Text, categories, center, limit and locales are mapped to the offline search engine with the same rules the online server uses, so both paths can share one code path in the app.

      The callback may be invoked on a background thread (or synchronously, when the request completes without starting). If you update UI, post back to the main thread. The callback is invoked exactly once per start: a request with nothing to search (both text and categories are empty, or an autocomplete prefix is below the minimum length) completes with an empty result. Category-only requests are valid. A cancelled request completes with an ECANCELED error.

      Parameters:
      callback - callback that receives result vector objects or an error
      Returns:
      request ID that can be passed to cancel(long), or 0 if the request completed without starting
    • cancel

      public static void cancel(long requestID)
      Cancels a request started via startOnline(ResultsCallback) or startOffline(ResultsCallback). The callback of the cancelled request receives an ECANCELED error.
      Parameters:
      requestID - request ID returned by the start method