use of com.topcom.cms.es.vo.BoolQueryRequest in project topcom-cloud by 545314690.
the class StaffSentimentController method searchOneStaff.
// 后期改用多线程查询,临时单线程查询
private StaffSentiment searchOneStaff(Staff staff, StaffSentimentRequest request) {
StaffSentiment staffSentiment = new StaffSentiment();
staffSentiment.setId(String.valueOf(staff.getId()));
staffSentiment.setStaff(staff.toMap());
BoolQueryRequest boolRequest = new BoolQueryRequest();
boolRequest.setDate(request.getDate());
boolRequest.setGroupName("nlp.sentiment.label");
boolRequest.setKeyword(new Keyword(staff.getExpression()));
PageRequest page = new PageRequest(1, 10);
page.setOrders(request.getSortBy());
boolRequest.setPage(page);
boolRequest.setFiled(request.getFiled());
boolRequest.setType(request.getArticleType());
// 情感值
Map kvMap = KV.kvList2Map(esManager.filterAndGroupBy(boolRequest));
staffSentiment.setNEG((Long) (kvMap.get("NEG") == null ? 0 : kvMap.get("NEG")));
staffSentiment.setNEU((Long) (kvMap.get("NEU") == null ? 0 : kvMap.get("NEU")));
staffSentiment.setPOS((Long) (kvMap.get("POS") == null ? 0 : kvMap.get("POS")));
// 总数 以及条新闻,最新?还是最负面?
Page articlePage = esManager.findByMustShouldDateInType(boolRequest);
if (articlePage.getTotalElements() > 0) {
staffSentiment.setArticle((Map) articlePage.getContent().get(0));
staffSentiment.setTotal(articlePage.getTotalElements());
Long time = Long.valueOf(((Map) articlePage.getContent().get(0)).get("pubTime").toString());
staffSentiment.setNewsDate(new Date(time));
}
return staffSentiment;
}
use of com.topcom.cms.es.vo.BoolQueryRequest in project topcom-cloud by 545314690.
the class WarningManagerImpl method getSubjectWarningInfo.
@Deprecated
@Override
public Page<News> getSubjectWarningInfo(CustomSubject subject, int pageNum, int limit) {
WarningTask warning = subject.getWarning();
if (warning == null) {
return new PageImpl<News>(new ArrayList<News>());
}
BoolQueryRequest request = new BoolQueryRequest();
request.setType(null);
request.setFiled(null);
request.setKeyword(new Keyword(subject.getMustWord(), subject.getShouldWord(), subject.getMustNotWord()));
// 本次预警时间
Date thisWarningDate = new Date();
// 上次预警时间
Date lastWarningDate = warning.getLastWarningDate();
if (lastWarningDate == null) {
lastWarningDate = subject.getStartDate();
}
request.setDate(new DateParam(DateUtil.dateToString(lastWarningDate), DateUtil.dateToString(thisWarningDate)));
request.setPage(new PageRequest(pageNum, limit, new Order(Sort.Direction.DESC, "pubTime")));
List<KV> kvList = new ArrayList<>();
// 媒体类型
String[] type = warning.getType();
if (type != null && type.length > 0) {
kvList.add(new KV("type", type));
}
String[] sentimentLabel = warning.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;
}
use of com.topcom.cms.es.vo.BoolQueryRequest in project topcom-cloud by 545314690.
the class DescriptionManagerImpl method getmom.
private Object getmom(BoolQueryRequest boolQueryRequest, String type) {
DateParam lastDateparam = lastDateparam(boolQueryRequest.getDate(), type);
Page thisMonth = allESDataService.findByMustShouldDateInType(boolQueryRequest);
BoolQueryRequest boolQueryRequestLast = new BoolQueryRequest(lastDateparam, boolQueryRequest.getKeyword());
boolQueryRequestLast.setType(boolQueryRequest.getType());
boolQueryRequestLast.setSearchKv(boolQueryRequest.getSearchKv());
boolQueryRequestLast.setPage(boolQueryRequest.getPage());
boolQueryRequestLast.setFiled(boolQueryRequest.getFiled());
Page lastMonth = allESDataService.findByMustShouldDateInType(boolQueryRequestLast);
return (double) (thisMonth.getTotalElements() - lastMonth.getTotalElements()) / lastMonth.getTotalElements();
}
use of com.topcom.cms.es.vo.BoolQueryRequest 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;
}
Aggregations