code: public SearchResult getSuggestions(StaplerRequest req, String query) {
          Set<String> paths = new HashSet<>();  // paths already added, to control duplicates
          SearchResultImpl r = new SearchResultImpl();
          int max = req.hasParameter("max") ? Integer.parseInt(req.getParameter("max")) : 100;
          SearchableModelObject smo = findClosestSearchableModelObject(req);
          for (SuggestedItem i : suggest(makeSuggestIndex(req), query, smo)) {
              if(r.size()>=max) {
                  r.hasMoreResults = true;
                  break;
              }
              if(paths.add(i.getPath()))
                  r.add(i);
          }
          return r;
      }
docs: Gets the list of suggestions that match the given query.
  
  @return
  can be empty but never null. The size of the list is always smaller than
  a certain threshold to avoid showing too many options.