Search in sources :

Example 6 with KV

use of com.topcom.cms.es.vo.KV in project topcom-cloud by 545314690.

the class WarningLogManagerImpl method getWarningInfo.

@Override
public Page getWarningInfo(WarningLog warningLog, int pageNum, int limit) {
    if (warningLog == null) {
        return new PageImpl<>(new ArrayList<>());
    }
    BoolQueryRequest request = new BoolQueryRequest();
    request.setType(null);
    request.setFiled(warningLog.getField());
    request.setKeyword(new Keyword(warningLog.getMustWord(), warningLog.getShouldWord(), warningLog.getMustNotWord()));
    /**
     * 数据发布时间:暂定三天内
     */
    // TODO:三天内合适不?
    // Date now = new Date();
    // request.setDate(new DateParam(DateUtil.dateToString(DateUtils.addDays(now, -3)), DateUtil.dateToString(now)));
    /**
     * 数据保存时间
     */
    request.setDateCreated(new DateParam(warningLog.getStartDate(), warningLog.getEndDate()));
    Date now = request.getDateCreated().endDate();
    request.setDate(new DateParam(DateUtil.dateToString(DateUtils.addDays(now, -3)), DateUtil.dateToString(now)));
    request.setPage(new PageRequest(pageNum, limit, new Order(Sort.Direction.DESC, "pubTime")));
    List<KV> kvList = new ArrayList<>();
    // 媒体类型
    String[] type = warningLog.getType();
    if (type != null && type.length > 0) {
        request.setType(type);
    }
    String[] sentimentLabel = warningLog.getSentimentLabel();
    // 情感类型
    if (sentimentLabel != null && sentimentLabel.length > 0) {
        kvList.add(new KV("nlp.sentiment.label", sentimentLabel));
    }
    request.setSearchKv(kvList);
    final Page page = newsService.findByMustShouldDateInType(request);
    return page;
}
Also used : PageImpl(org.springframework.data.domain.PageImpl) Order(com.topcom.cms.common.page.Order) BoolQueryRequest(com.topcom.cms.es.vo.BoolQueryRequest) Keyword(com.topcom.cms.es.vo.Keyword) ArrayList(java.util.ArrayList) Page(org.springframework.data.domain.Page) KV(com.topcom.cms.es.vo.KV) Date(java.util.Date) PageRequest(com.topcom.cms.common.page.PageRequest) DateParam(com.topcom.cms.common.page.DateParam)

Aggregations

KV (com.topcom.cms.es.vo.KV)6 Keyword (com.topcom.cms.es.vo.Keyword)4 DateParam (com.topcom.cms.common.page.DateParam)3 Order (com.topcom.cms.common.page.Order)2 PageRequest (com.topcom.cms.common.page.PageRequest)2 BoolQueryRequest (com.topcom.cms.es.vo.BoolQueryRequest)2 Accident (com.topcom.cms.mongo.domain.Accident)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 Page (org.springframework.data.domain.Page)2 PageImpl (org.springframework.data.domain.PageImpl)2 News (com.topcom.cms.data.domain.News)1 AggRequest (com.topcom.cms.es.vo.AggRequest)1 WarningTask (com.topcom.cms.yuqing.domain.WarningTask)1