Exemplo n.º 1
0
  public static SearchResult search(Mapx map) {
    SearchParameters sps = new SearchParameters();
    String site = map.getString("site");
    String id = map.getString("id");
    String catalog = map.getString("catalog");
    if (StringUtil.isEmpty(catalog)) {
      catalog = map.getString("Catalog");
    }
    String order = map.getString("order");
    String time = map.getString("time");
    String keyword = map.getString("keyword");
    String query = map.getString("query");
    if (StringUtil.isEmpty(keyword)) {
      keyword = query;
    }
    String page = map.getString("page");
    String size = map.getString("size");

    if (StringUtil.isEmpty(id)) {
      id = SearchAPI.getIndexIDBySiteID(site);
    }

    if (StringUtil.isNotEmpty(keyword)) {
      sps.addFulltextField("Title", keyword, false);
      sps.addFulltextField("Content", keyword, false);
      sps.addFulltextField("_Keyword", keyword, true);
    }

    if ("time".equalsIgnoreCase(order)) {
      sps.setSortField("PublishDate", 3, true);
    }

    if (StringUtil.isNotEmpty(time)) {
      Date today = new Date();
      String StartDate = DateUtil.toString(DateUtil.addDay(today, -36500));
      if (time.equals("week")) StartDate = DateUtil.toString(DateUtil.addDay(today, -7));
      else if (time.equals("month")) StartDate = DateUtil.toString(DateUtil.addDay(today, -30));
      else if (time.equals("quarter")) {
        StartDate = DateUtil.toString(DateUtil.addDay(today, -90));
      }
      String EndDate = "2999-01-01";
      sps.setDateRange("PublishDate", StartDate, EndDate);
    }
    if (StringUtil.isNotEmpty(catalog)) {
      sps.addLeftLikeField("CatalogInnerCode", catalog);
    }
    if (StringUtil.isNotEmpty(page)) {
      sps.setPageIndex(Integer.parseInt(page) - 1);
    }
    if (StringUtil.isNotEmpty(size)) {
      sps.setPageSize(Integer.parseInt(size));
    }
    if (StringUtil.isEmpty(id)) {
      SearchResult sr = new SearchResult();
      sr.Data = new DataTable();
      return sr;
    }
    sps.setIndexID(Long.parseLong(id));
    return ArticleIndexer.search(sps);
  }
Exemplo n.º 2
0
 public void onPeriodChange(int type, long current) {
   if (type == 1) {
     String period = DateUtil.toString(new Date(current), "yyyyMMdd");
     if (period.endsWith("01")) {
       this.isNewMonth = true;
       VisitCount.getInstance().clearType(getStatType(), true);
     } else {
       VisitCount.getInstance().clearType(getStatType(), false);
       VisitCount.getInstance().clearSubType(getStatType(), "Keyword", true);
       VisitCount.getInstance().clearSubType(getStatType(), "Referer", true);
     }
   }
 }
Exemplo n.º 3
0
 public void update(
     Transaction tran, VisitCount vc, long current, boolean newMonthFlag, boolean isNewPeriod) {
   if (!newMonthFlag) {
     Date today = new Date(current);
     if (isNewPeriod) {
       today = DateUtil.addDay(today, -1);
     }
     String period = DateUtil.toString(today, "yyyyMM");
     long[] sites = vc.getSites();
     for (int i = 0; i < sites.length; ++i) {
       URLStat.dealNotNeedInsertItem(vc, period, sites[i], "Source", "Referer");
       URLStat.dealNotNeedInsertItem(vc, period, sites[i], "Source", "Keyword");
     }
   }
   super.update(tran, vc, current, newMonthFlag, isNewPeriod);
 }