예제 #1
0
 public Page<Weibo> searchWeibo(
     Map<String, Object> searchParams,
     int pageNumber,
     int pageSize,
     String sortType,
     boolean and,
     int e_type) {
   PageRequest pageRequest = buildPageRequest(pageNumber, pageSize, sortType);
   List<Weibo> array = new ArrayList<Weibo>();
   Date fromDate = (Date) searchParams.get("date_from");
   Date toDate = (Date) searchParams.get("date_to");
   String pageProperty = pageRequest.getSort().iterator().next().getProperty();
   int total = 0;
   String word = searchParams.get("all").toString();
   if (searchParams.containsKey("field")) {
     total =
         elasticSearch.search(
             word,
             searchParams.get("field").toString(),
             (int) searchParams.get("field_from"),
             (int) searchParams.get("field_to"),
             (pageNumber - 1) * pageSize,
             pageSize,
             array,
             pageProperty,
             SortOrder.DESC,
             fromDate,
             toDate,
             and,
             e_type);
   } else {
     total =
         elasticSearch.search(
             word,
             (pageNumber - 1) * pageSize,
             pageSize,
             array,
             pageProperty,
             SortOrder.DESC,
             fromDate,
             toDate,
             and,
             e_type);
   }
   // System.out.println("searchWeibo:" + fromDate + "\t" + toDate + "\t" + and);
   if (changsha) {
     for (Weibo weibo : array) {
       hbaseWeiboMsg.getHeadPic_changsha(weibo);
     }
   } else {
     array = hbaseWeiboMsg.fillWeibos(array);
     setHilight(array, word);
   }
   Page<Weibo> resultPage = new PageImpl<Weibo>(array, pageRequest, total);
   return resultPage;
 }
예제 #2
0
  public Weibo findWeiboById(Long id) {

    Weibo w = elasticSearch.getWeibo(id.toString());
    if (changsha) {
      hbaseWeiboMsg.getHeadPic_changsha(w);
    } else {
      w =
          hbaseWeiboMsg.getWeibo(
              DateFormatUtils.format(w.getReleaseDate(), "yyyyMMddHHmmss") + "-" + id.toString());
    }
    // mongoDBClient.findWeiboById(w);
    return w;
  }
예제 #3
0
 public List<Weibo> getLatestWeibos(int num) {
   List<Weibo> weibos = new ArrayList();
   Object object;
   object =
       elasticSearch.search(
           null, 0, num, weibos, "releasedate", SortOrder.DESC, null, null, true, 0);
   weibos = hbaseWeiboMsg.fillWeibos(weibos);
   return weibos;
 }
예제 #4
0
 public List<Weibo> searchRelatedWeibo(
     String wd,
     Date from,
     Date to,
     int pageNumber,
     int pageSize,
     String sortType,
     boolean and,
     int e_type)
     throws Exception {
   List<Weibo> result = new ArrayList<>();
   System.out.println(from + "\t" + to);
   elasticSearch.search(
       wd, 0, pageSize, result, sortType, SortOrder.DESC, from, to, false, e_type);
   result = hbaseWeiboMsg.fillWeibos(result);
   // System.out.println("searchRelatedWeibo:" + from + "\t" + to);
   // result = filterWeibo(result);
   return result;
 }
예제 #5
0
 private Page<Weibo> searchLongWeibo(
     Map<String, Object> searchParams, int pageNumber, int pageSize, String sortType) {
   // TODO Auto-generated method stub
   PageRequest pageRequest = buildPageRequest(pageNumber, pageSize, sortType);
   List<Weibo> array = new ArrayList<Weibo>();
   Date fromDate = (Date) searchParams.get("date_from");
   Date toDate = (Date) searchParams.get("date_to");
   String pageProperty = pageRequest.getSort().iterator().next().getProperty();
   int total = 0;
   String word = searchParams.get("all").toString();
   total =
       longWeiboIndex.search(
           word,
           (pageNumber - 1) * pageSize,
           pageSize,
           array,
           pageProperty,
           SortOrder.DESC,
           fromDate,
           toDate);
   array = hbaseWeiboMsg.fillWeibos(array);
   Page<Weibo> resultPage = new PageImpl<Weibo>(array, pageRequest, total);
   return resultPage;
 }
예제 #6
0
 public List<Weibo> getWeibos(List<String> mids) {
   return hbaseWeiboMsg.getWeibos(mids);
 }