Beispiel #1
0
  /**
   * Perform the search
   *
   * @return a list of page names that match the search criteria
   */
  public SearchList search() {

    if (searchResults == null && errorMessage == null) {
      if (search != null && search.trim().length() > 0) {

        List<String> l = getSearchSites(getToolPropertySiteIds());
        long start = System.currentTimeMillis();
        int searchStart = requestPage * pagesize;
        int searchEnd = searchStart + pagesize;
        try {
          searchResults =
              searchService.search(search, l, searchStart, searchEnd, filterName, sortName);
          if (searchResults != null && searchResults.size() < 3) {
            if ((searchResults.size() > 0 && searchResults.get(0).getScore() < 1)) {
              log.debug("closest match: " + searchResults.get(0).getScore());
              String sug = searchService.getSearchSuggestion(search);
              log.debug("got suggestion: " + sug);
              this.searchTermSuggestion = sug;
            } else if (searchResults.size() == 0) {
              log.debug("No hits getting suggestion");
              String sug = searchService.getSearchSuggestion(search);
              log.debug("got suggestion: " + sug);
              this.searchTermSuggestion = sug;
            }
          } else if (searchResults == null || searchResults.size() == 0) {
            log.debug("No hits getting suggestion");
            String sug = searchService.getSearchSuggestion(search);
            log.debug("got suggestion: " + sug);
            this.searchTermSuggestion = sug;
          }
        } catch (Exception ex) {
          ex.printStackTrace();
          errorMessage = ex.getMessage();
          log.warn(
              "Search Error encoutered, generated by a user action "
                  + ex.getClass().getName()
                  + ":"
                  + ex.getMessage());
          log.debug("Search Error Traceback ", ex);
        }
        long end = System.currentTimeMillis();
        timeTaken = 0.001 * (end - start);
      }
    }

    return searchResults;
  }
Beispiel #2
0
 /** {@inheritDoc} */
 public boolean isSearchServer() {
   return searchService.isSearchServer();
 }