@Override
  protected List<TransportRoute> getFilteredResult() {
    final List<TransportRoute> allRoutes = getRepository().all();
    final List<TransportRoute> filteredRoutes = new ArrayList<TransportRoute>();

    for (final TransportRoute r : allRoutes) {
      if (MatchUtil.matchContains(searchBean.getName(), r.getName())
          && MatchUtil.matchContains(searchBean.getDescription(), r.getDescription())) {
        filteredRoutes.add(r);
      }
    }

    return filteredRoutes;
  }
Ejemplo n.º 2
0
 public void close() throws IOException {
   if (searchBean != null) {
     searchBean.close();
   }
   if (fs != null) {
     fs.close();
   }
 }
Ejemplo n.º 3
0
 public HitDetails getDetails(Hit hit) throws IOException {
   return searchBean.getDetails(hit);
 }
Ejemplo n.º 4
0
 public HitDetails[] getDetails(Hit[] hits) throws IOException {
   return searchBean.getDetails(hits);
 }
Ejemplo n.º 5
0
 public String getExplanation(Query query, Hit hit) throws IOException {
   return searchBean.getExplanation(query, hit);
 }
Ejemplo n.º 6
0
  /**
   * Search for pages matching a query, eliminating excessive hits with matching values for a named
   * field. Hits after the first <code>maxHitsPerDup</code> are removed from results. The remaining
   * hits have {@link Hit#moreFromDupExcluded()} set.
   *
   * <p>If maxHitsPerDup is zero then all hits are returned.
   *
   * @param query query
   * @param numHits number of requested hits
   * @param maxHitsPerDup the maximum hits returned with matching values, or zero
   * @param dedupField field name to check for duplicates
   * @param sortField Field to sort on (or null if no sorting).
   * @param reverse True if we are to reverse sort by <code>sortField</code>.
   * @return Hits the matching hits
   * @throws IOException
   */
  public Hits search(
      Query query,
      int numHits,
      int maxHitsPerDup,
      String dedupField,
      String sortField,
      boolean reverse)
      throws IOException {
    if (maxHitsPerDup <= 0) // disable dup checking
    return search(query, numHits, dedupField, sortField, reverse);

    final float rawHitsFactor = this.conf.getFloat("searcher.hostgrouping.rawhits.factor", 2.0f);
    int numHitsRaw = (int) (numHits * rawHitsFactor);
    if (LOG.isInfoEnabled()) {
      LOG.info("searching for " + numHitsRaw + " raw hits");
    }
    Hits hits = searchBean.search(query, numHitsRaw, dedupField, sortField, reverse);
    final long total = hits.getTotal();
    final Map<String, DupHits> dupToHits = new HashMap<String, DupHits>();
    final List<Hit> resultList = new ArrayList<Hit>();
    final Set<Hit> seen = new HashSet<Hit>();
    final List<String> excludedValues = new ArrayList<String>();
    boolean totalIsExact = true;
    for (int rawHitNum = 0; rawHitNum < hits.getTotal(); rawHitNum++) {
      // get the next raw hit
      if (rawHitNum >= hits.getLength()) {
        // optimize query by prohibiting more matches on some excluded values
        final Query optQuery = (Query) query.clone();
        for (int i = 0; i < excludedValues.size(); i++) {
          if (i == MAX_PROHIBITED_TERMS) break;
          optQuery.addProhibitedTerm(excludedValues.get(i), dedupField);
        }
        numHitsRaw = (int) (numHitsRaw * rawHitsFactor);
        if (LOG.isInfoEnabled()) {
          LOG.info("re-searching for " + numHitsRaw + " raw hits, query: " + optQuery);
        }
        hits = searchBean.search(optQuery, numHitsRaw, dedupField, sortField, reverse);
        if (LOG.isInfoEnabled()) {
          LOG.info("found " + hits.getTotal() + " raw hits");
        }
        rawHitNum = -1;
        continue;
      }

      final Hit hit = hits.getHit(rawHitNum);
      if (seen.contains(hit)) continue;
      seen.add(hit);

      // get dup hits for its value
      final String value = hit.getDedupValue();
      DupHits dupHits = dupToHits.get(value);
      if (dupHits == null) dupToHits.put(value, dupHits = new DupHits());

      // does this hit exceed maxHitsPerDup?
      if (dupHits.size() == maxHitsPerDup) { // yes -- ignore the hit
        if (!dupHits.maxSizeExceeded) {

          // mark prior hits with moreFromDupExcluded
          for (int i = 0; i < dupHits.size(); i++) {
            dupHits.get(i).setMoreFromDupExcluded(true);
          }
          dupHits.maxSizeExceeded = true;

          excludedValues.add(value); // exclude dup
        }
        totalIsExact = false;
      } else { // no -- collect the hit
        resultList.add(hit);
        dupHits.add(hit);

        // are we done?
        // we need to find one more than asked for, so that we can tell if
        // there are more hits to be shown
        if (resultList.size() > numHits) break;
      }
    }

    final Hits results = new Hits(total, resultList.toArray(new Hit[resultList.size()]));
    results.setTotalIsExact(totalIsExact);
    return results;
  }
Ejemplo n.º 7
0
  public Hits search(Query query, int numHits, String dedupField, String sortField, boolean reverse)
      throws IOException {

    return searchBean.search(query, numHits, dedupField, sortField, reverse);
  }
Ejemplo n.º 8
0
  public List<SearchBean> loadXmlList(
      HttpServletRequest request, SearchParam pm, String searchUrl, String section_nm)
      throws Exception {

    List<SearchBean> xmlList = new ArrayList<SearchBean>();

    // xml 파싱
    XmlParser section = new XmlParser(searchUrl);

    System.out.println(section.length());
    for (int i = 0; i < section.length(); i++) {

      // 전체 목록 수
      String totalCount = KJFUtil.print(section.getInfoValue(i, "totcnt"), "0");

      // 페이지별 목록 수
      int rowPerPage = KJFUtil.str2int(pm.getRowPerPage());

      // 현재 페이지 번호
      int nowPage = 1;
      nowPage = KJFUtil.isEmpty(pm.getNowPage()) ? 1 : Integer.parseInt(pm.getNowPage());

      if (rowPerPage == 0) rowPerPage = Integer.parseInt(totalCount);
      if ((rowPerPage * nowPage) - Integer.parseInt(totalCount) > rowPerPage) nowPage = 1;

      pm.setTotalCount(totalCount);
      pm.setNowPage(String.valueOf(nowPage));

      //  검색 결과 XML 에서 추출 태그 변경
      if (section.getName(i).indexOf(section_nm) != -1) {
        System.out.println(section.getName(i));
        System.out.println("에 대한 약 " + totalCount + "개 결과 중 ");
      } else {
        continue;
      }

      // doc print
      if (section.isDocs(i)) {

        for (int j = 0; j < section.docLength(i); j++) {

          // att node들은 HashMap객체에 담겨져 있다.
          // 사용할때는  att노드의 Attribute name의 value를 key값으로 넣어준다.
          // xml data 중 <section name="title"> 필드 명
          // i 값은 section 순서
          if (section.getName(i).indexOf(section_nm) != -1) {

            System.out.println(j);

            SearchBean scBean = new SearchBean();

            // 게시판 관련
            scBean.setCt_id(section.getDocValue(i, j, "^CT_ID:"));
            scBean.setBoard_seq(section.getDocValue(i, j, "^BOARD_SEQ:"));
            scBean.setSubject(section.getDocValue(i, j, "^SUBJECT:"));
            scBean.setContent(section.getDocValue(i, j, "^CONTENT:"));

            // 웹페이지 관련
            scBean.setMenu_id(section.getDocValue(i, j, "^MENU_ID:"));
            scBean.setM_menu(section.getDocValue(i, j, "^M_MENU:"));
            scBean.setL_menu(section.getDocValue(i, j, "^L_MENU:"));
            scBean.setS_munu(section.getDocValue(i, j, "^S_MENU:"));
            scBean.setTitle(section.getDocValue(i, j, "^TITLE:"));
            scBean.setBody(section.getDocValue(i, j, "^CONTENT:"));

            System.out.println(section.getDocValue(i, j, "^tit:"));
            System.out.println(section.getDocValue(i, j, "^url:"));

            xmlList.add(scBean);
          }
        } // end of  for
      }
    }

    /** **** 검색조건 초기값 ********** */
    request.setAttribute("pm", pm);

    return xmlList;
  }
Ejemplo n.º 9
0
 public PageLinkWrapper getPageLink(SearchBean searchBean) {
   return new PageLinkWrapper(getPrintName(), 1, searchBean.getSearchPhrase(), name());
 }