Пример #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
 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;
 }