提交 a6a40fad 作者: 925993793@qq.com

【fix】资讯列表高级检索增加 全文 逻辑;增加是否启用元搜索逻辑

上级 d9d24f75
...@@ -16,6 +16,7 @@ import com.zzsn.event.service.IEventService; ...@@ -16,6 +16,7 @@ import com.zzsn.event.service.IEventService;
import com.zzsn.event.service.IKeyWordsService; import com.zzsn.event.service.IKeyWordsService;
import com.zzsn.event.service.ISubjectInfoSourceMapService; import com.zzsn.event.service.ISubjectInfoSourceMapService;
import com.zzsn.event.service.LabelEntityService; import com.zzsn.event.service.LabelEntityService;
import com.zzsn.event.service.impl.ConfigurationMessageService;
import com.zzsn.event.util.HttpUtil; import com.zzsn.event.util.HttpUtil;
import com.zzsn.event.util.ObjectUtil; import com.zzsn.event.util.ObjectUtil;
import com.zzsn.event.util.RedisUtil; import com.zzsn.event.util.RedisUtil;
...@@ -57,7 +58,8 @@ public class EventManageController { ...@@ -57,7 +58,8 @@ public class EventManageController {
private IXxlJobInfoService iXxlJobInfoService; private IXxlJobInfoService iXxlJobInfoService;
@Autowired @Autowired
private ISubjectInfoSourceMapService subjectInfoSourceMapService; private ISubjectInfoSourceMapService subjectInfoSourceMapService;
@Autowired
private ConfigurationMessageService configurationMessageService;
@Autowired @Autowired
private IKeyWordsService keyWordsService; private IKeyWordsService keyWordsService;
...@@ -149,6 +151,7 @@ public class EventManageController { ...@@ -149,6 +151,7 @@ public class EventManageController {
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
//插入xxlJob //插入xxlJob
iXxlJobInfoService.eventInsert(event); iXxlJobInfoService.eventInsert(event);
/*-------------------------------------------------------------老采集逻辑---------------*/
//关键词入缓存 //关键词入缓存
KeyWordsDTO redisKeywordDTO = new KeyWordsDTO(); KeyWordsDTO redisKeywordDTO = new KeyWordsDTO();
BeanUtils.copyProperties(keyWords, redisKeywordDTO); BeanUtils.copyProperties(keyWords, redisKeywordDTO);
...@@ -160,8 +163,11 @@ public class EventManageController { ...@@ -160,8 +163,11 @@ public class EventManageController {
iXxlJobInfoService.keyWordsInsert(redisKeywordDTO); iXxlJobInfoService.keyWordsInsert(redisKeywordDTO);
//为了立即响应,关键词新增时放入消息队列 //为了立即响应,关键词新增时放入消息队列
kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO)); kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO));
/*-----------------------------------------------------------------老采集逻辑---------------*/
//通知采集
configurationMessageService.bindKeyWordsEventSend(event.getId());
//事件分析
kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode()); kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode());
}); });
return Result.OK(); return Result.OK();
} else { } else {
...@@ -188,6 +194,7 @@ public class EventManageController { ...@@ -188,6 +194,7 @@ public class EventManageController {
.set(KeyWords::getKeyWord, keywordsVO.getKeyword()) .set(KeyWords::getKeyWord, keywordsVO.getKeyword())
.set(KeyWords::getExclusionWord, keywordsVO.getExclusionWord())); .set(KeyWords::getExclusionWord, keywordsVO.getExclusionWord()));
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
/*-----------------------------------------------------------------老采集逻辑---------------*/
KeyWordsDTO redisKeywordDTO = new KeyWordsDTO(); KeyWordsDTO redisKeywordDTO = new KeyWordsDTO();
BeanUtils.copyProperties(keywordsVO, redisKeywordDTO); BeanUtils.copyProperties(keywordsVO, redisKeywordDTO);
redisKeywordDTO.setKeyWord(keywordsVO.getKeyword()); redisKeywordDTO.setKeyWord(keywordsVO.getKeyword());
...@@ -197,6 +204,9 @@ public class EventManageController { ...@@ -197,6 +204,9 @@ public class EventManageController {
redisUtil.set(Constants.KEY_WORDS_TO_REDIS_PREFIX + keywordsVO.getWordsCode(), redisKeywordDTO); redisUtil.set(Constants.KEY_WORDS_TO_REDIS_PREFIX + keywordsVO.getWordsCode(), redisKeywordDTO);
//为了立即响应,关键词编辑时放入消息队列 //为了立即响应,关键词编辑时放入消息队列
kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO)); kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO));
/*-----------------------------------------------------------------老采集逻辑---------------*/
//通知采集
configurationMessageService.bindKeyWordsEventSend(addEventParam.getId());
}); });
return Result.OK(); return Result.OK();
} else { } else {
...@@ -250,7 +260,6 @@ public class EventManageController { ...@@ -250,7 +260,6 @@ public class EventManageController {
keyWordsService.remove(Wrappers.<KeyWords>lambdaQuery().eq(KeyWords::getWordsCode, wordsCode)); keyWordsService.remove(Wrappers.<KeyWords>lambdaQuery().eq(KeyWords::getWordsCode, wordsCode));
redisUtil.del(Constants.KEY_WORDS_TO_REDIS_PREFIX + wordsCode); redisUtil.del(Constants.KEY_WORDS_TO_REDIS_PREFIX + wordsCode);
iXxlJobInfoService.deleteByInfosourceCode(wordsCode); iXxlJobInfoService.deleteByInfosourceCode(wordsCode);
//todo 是否删除对应的资讯数据
} }
}); });
return Result.OK(); return Result.OK();
...@@ -285,7 +294,6 @@ public class EventManageController { ...@@ -285,7 +294,6 @@ public class EventManageController {
} }
} }
}); });
//todo 是否删除对应的资讯数据
return Result.OK(); return Result.OK();
} }
......
...@@ -8,6 +8,7 @@ import com.zzsn.event.constant.Result; ...@@ -8,6 +8,7 @@ import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.*; import com.zzsn.event.entity.*;
import com.zzsn.event.enums.CodePrefixEnum; import com.zzsn.event.enums.CodePrefixEnum;
import com.zzsn.event.service.*; import com.zzsn.event.service.*;
import com.zzsn.event.service.impl.ConfigurationMessageService;
import com.zzsn.event.util.CodeGenerateUtil; import com.zzsn.event.util.CodeGenerateUtil;
import com.zzsn.event.util.CronUtil; import com.zzsn.event.util.CronUtil;
import com.zzsn.event.util.DateUtil; import com.zzsn.event.util.DateUtil;
...@@ -66,6 +67,8 @@ public class EventApi { ...@@ -66,6 +67,8 @@ public class EventApi {
private IEventTagService eventTagService; private IEventTagService eventTagService;
@Autowired @Autowired
private EventRegionMapService eventRegionMapService; private EventRegionMapService eventRegionMapService;
@Autowired
private ConfigurationMessageService configurationMessageService;
@Value("${kafka.topic.event.run:}") @Value("${kafka.topic.event.run:}")
private String EVENT_MODEL_KAFKA_CHANNEL; private String EVENT_MODEL_KAFKA_CHANNEL;
...@@ -97,6 +100,8 @@ public class EventApi { ...@@ -97,6 +100,8 @@ public class EventApi {
iXxlJobInfoService.keyWordsInsert(redisKeywordDTO); iXxlJobInfoService.keyWordsInsert(redisKeywordDTO);
//为了立即响应,关键词新增时放入一个首次录入消息队列 //为了立即响应,关键词新增时放入一个首次录入消息队列
kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO)); kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO));
//通知采集
configurationMessageService.bindKeyWordsEventSend(event.getId());
kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode()); kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode());
}); });
return Result.OK(event); return Result.OK(event);
...@@ -131,6 +136,8 @@ public class EventApi { ...@@ -131,6 +136,8 @@ public class EventApi {
redisUtil.set(Constants.KEY_WORDS_TO_REDIS_PREFIX + keywordsVO.getWordsCode(), redisKeywordDTO); redisUtil.set(Constants.KEY_WORDS_TO_REDIS_PREFIX + keywordsVO.getWordsCode(), redisKeywordDTO);
//为了立即响应,关键词新增时放入一个首次录入消息队列 //为了立即响应,关键词新增时放入一个首次录入消息队列
kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO)); kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO));
//通知采集
configurationMessageService.bindKeyWordsEventSend(addEventVO.getId());
}); });
return Result.OK(); return Result.OK();
} else { } else {
......
...@@ -16,6 +16,7 @@ import com.zzsn.event.service.EventSimpleService; ...@@ -16,6 +16,7 @@ import com.zzsn.event.service.EventSimpleService;
import com.zzsn.event.service.IEventService; import com.zzsn.event.service.IEventService;
import com.zzsn.event.service.IKeyWordsService; import com.zzsn.event.service.IKeyWordsService;
import com.zzsn.event.service.InformationService; import com.zzsn.event.service.InformationService;
import com.zzsn.event.service.impl.ConfigurationMessageService;
import com.zzsn.event.util.*; import com.zzsn.event.util.*;
import com.zzsn.event.util.user.UserUtil; import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo; import com.zzsn.event.util.user.UserVo;
...@@ -62,6 +63,8 @@ public class EventDataController { ...@@ -62,6 +63,8 @@ public class EventDataController {
@Autowired @Autowired
private InformationService informationService; private InformationService informationService;
@Autowired @Autowired
private ConfigurationMessageService configurationMessageService;
@Autowired
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Resource @Resource
private KafkaTemplate<String, String> kafkaTemplate; private KafkaTemplate<String, String> kafkaTemplate;
...@@ -241,6 +244,8 @@ public class EventDataController { ...@@ -241,6 +244,8 @@ public class EventDataController {
iXxlJobInfoService.keyWordsInsert(redisKeywordDTO); iXxlJobInfoService.keyWordsInsert(redisKeywordDTO);
//为了立即响应,关键词新增时放入一个首次录入消息队列 //为了立即响应,关键词新增时放入一个首次录入消息队列
kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO)); kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO));
//通知采集
configurationMessageService.bindKeyWordsEventSend(event.getId());
kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode()); kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode());
}); });
return Result.OK(); return Result.OK();
...@@ -307,6 +312,8 @@ public class EventDataController { ...@@ -307,6 +312,8 @@ public class EventDataController {
redisUtil.set(Constants.KEY_WORDS_TO_REDIS_PREFIX + keywordsVO.getWordsCode(), redisKeywordDTO); redisUtil.set(Constants.KEY_WORDS_TO_REDIS_PREFIX + keywordsVO.getWordsCode(), redisKeywordDTO);
//为了立即响应,关键词新增时放入一个首次录入消息队列 //为了立即响应,关键词新增时放入一个首次录入消息队列
kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO)); kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO));
//通知采集
configurationMessageService.bindKeyWordsEventSend(addEventVO.getId());
}); });
return Result.OK(); return Result.OK();
} else { } else {
......
...@@ -2321,8 +2321,7 @@ public class EsService { ...@@ -2321,8 +2321,7 @@ public class EsService {
String rule = item.getString("rule"); String rule = item.getString("rule");
String field = item.getString("field"); String field = item.getString("field");
String val = item.getString("val"); String val = item.getString("val");
if ("date".equals(type)) { if ("date".equals(type)) { //日期类型处理
//日期类型处理
if ("eq".equals(rule)) { if ("eq".equals(rule)) {
builder2.must(QueryBuilders.rangeQuery(field).from(val + "T00:00:00").to(val + "T23:59:59")); builder2.must(QueryBuilders.rangeQuery(field).from(val + "T00:00:00").to(val + "T23:59:59"));
} }
...@@ -2337,8 +2336,7 @@ public class EsService { ...@@ -2337,8 +2336,7 @@ public class EsService {
} else if ("le".equals(rule)) { } else if ("le".equals(rule)) {
builder2.must(QueryBuilders.rangeQuery(field).to((val + "T23:59:59"))); builder2.must(QueryBuilders.rangeQuery(field).to((val + "T23:59:59")));
} }
} else if ("list".equals(type)) { } else if ("list".equals(type)) { //列表(数组)类查询
//列表(数组)类查询
if ("eq".equals(rule)) { if ("eq".equals(rule)) {
builder2.must(QueryBuilders.termQuery(field + ".keyword", val)); builder2.must(QueryBuilders.termQuery(field + ".keyword", val));
} else if ("ne".equals(rule)) { } else if ("ne".equals(rule)) {
...@@ -2362,9 +2360,27 @@ public class EsService { ...@@ -2362,9 +2360,27 @@ public class EsService {
builder2.must(wordAllBoolQuery); builder2.must(wordAllBoolQuery);
} }
} }
} else if ("string".equals(type)) { } else if ("string".equals(type)) { //文本类查询
//文本类查询 if ("fullText".equals(field)) {
if ("eq".equals(rule)) { BoolQueryBuilder fullTextBoolQuery = multiMatchQuery(val);
if ("like".equals(rule)) {
builder2.must(fullTextBoolQuery);
} else if ("not_like".equals(rule)) {
builder2.mustNot(fullTextBoolQuery);
} else if ("keyWordsGroup".equals(rule)) {
BoolQueryBuilder wordAllBoolQuery = QueryBuilders.boolQuery();
String[] andWords = val.split("\\+");
for (String words : andWords) {
String replace = words.replace("(", "").replace(")", "");
BoolQueryBuilder wordOrBoolQuery = QueryBuilders.boolQuery();
for (String word : replace.split("\\|")) {
wordOrBoolQuery.should(multiMatchQuery(word));
}
wordAllBoolQuery.must(wordOrBoolQuery);
}
builder2.must(wordAllBoolQuery);
}
} else if ("eq".equals(rule)) {
builder2.must(QueryBuilders.termQuery(field + ".keyword", val)); builder2.must(QueryBuilders.termQuery(field + ".keyword", val));
} else if ("ne".equals(rule)) { } else if ("ne".equals(rule)) {
builder2.mustNot(QueryBuilders.termQuery(field + ".keyword", val)); builder2.mustNot(QueryBuilders.termQuery(field + ".keyword", val));
...@@ -2377,19 +2393,17 @@ public class EsService { ...@@ -2377,19 +2393,17 @@ public class EsService {
} else if ("not_like".equals(rule)) { } else if ("not_like".equals(rule)) {
builder2.mustNot(QueryBuilders.matchPhrasePrefixQuery(field, val)); builder2.mustNot(QueryBuilders.matchPhrasePrefixQuery(field, val));
} else if ("keyWordsGroup".equals(rule)) { } else if ("keyWordsGroup".equals(rule)) {
if (StringUtils.isNotEmpty(val)) { BoolQueryBuilder wordAllBoolQuery = QueryBuilders.boolQuery();
BoolQueryBuilder wordAllBoolQuery = QueryBuilders.boolQuery(); String[] andWords = val.split("\\+");
String[] andWords = val.split("\\+"); for (String words : andWords) {
for (String words : andWords) { String replace = words.replace("(", "").replace(")", "");
String replace = words.replace("(", "").replace(")", ""); BoolQueryBuilder wordOrBoolQuery = QueryBuilders.boolQuery();
BoolQueryBuilder wordOrBoolQuery = QueryBuilders.boolQuery(); for (String word : replace.split("\\|")) {
for (String word : replace.split("\\|")) { wordOrBoolQuery.should(QueryBuilders.matchPhraseQuery(field, word));
wordOrBoolQuery.should(QueryBuilders.matchPhraseQuery(field, word));
}
wordAllBoolQuery.must(wordOrBoolQuery);
} }
builder2.must(wordAllBoolQuery); wordAllBoolQuery.must(wordOrBoolQuery);
} }
builder2.must(wordAllBoolQuery);
} }
} }
if ("or".equals(superQueryMatchType)) { if ("or".equals(superQueryMatchType)) {
...@@ -2405,4 +2419,13 @@ public class EsService { ...@@ -2405,4 +2419,13 @@ public class EsService {
} }
return null; return null;
} }
private BoolQueryBuilder multiMatchQuery(String word) {
BoolQueryBuilder fullTextBoolQuery = QueryBuilders.boolQuery();
String[] fullTextFields = new String[] {"title", "summary", "content"};
for (String fullTextField : fullTextFields) {
fullTextBoolQuery.should(QueryBuilders.matchPhraseQuery(fullTextField,word));
}
return fullTextBoolQuery;
}
} }
...@@ -238,6 +238,7 @@ public class KeyWordsServiceImpl extends ServiceImpl<KeyWordsMapper, KeyWords> i ...@@ -238,6 +238,7 @@ public class KeyWordsServiceImpl extends ServiceImpl<KeyWordsMapper, KeyWords> i
SubjectKeywordsMap subjectKeywordsMap = new SubjectKeywordsMap(); SubjectKeywordsMap subjectKeywordsMap = new SubjectKeywordsMap();
subjectKeywordsMap.setKeywordsId(keyWordsId); subjectKeywordsMap.setKeywordsId(keyWordsId);
subjectKeywordsMap.setSubjectId(event.getId()); subjectKeywordsMap.setSubjectId(event.getId());
subjectKeywordsMap.setMetaSearchFlag(1);
subjectKeywordsMapService.save(subjectKeywordsMap); subjectKeywordsMapService.save(subjectKeywordsMap);
} }
return keyWords; return keyWords;
...@@ -252,6 +253,7 @@ public class KeyWordsServiceImpl extends ServiceImpl<KeyWordsMapper, KeyWords> i ...@@ -252,6 +253,7 @@ public class KeyWordsServiceImpl extends ServiceImpl<KeyWordsMapper, KeyWords> i
SubjectKeywordsMap subjectKeywordsMap = new SubjectKeywordsMap(); SubjectKeywordsMap subjectKeywordsMap = new SubjectKeywordsMap();
subjectKeywordsMap.setKeywordsId(keyWordsId); subjectKeywordsMap.setKeywordsId(keyWordsId);
subjectKeywordsMap.setSubjectId(subjectId); subjectKeywordsMap.setSubjectId(subjectId);
subjectKeywordsMap.setMetaSearchFlag(1);
subjectKeywordsMapService.save(subjectKeywordsMap); subjectKeywordsMapService.save(subjectKeywordsMap);
} }
return keyWords; return keyWords;
......
...@@ -606,6 +606,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService { ...@@ -606,6 +606,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
bindType = "2"; bindType = "2";
} }
subjectKeywordsMap.setBindingType(bindType); subjectKeywordsMap.setBindingType(bindType);
subjectKeywordsMap.setMetaSearchFlag(1);
subjectKeywordsMapList.add(subjectKeywordsMap); subjectKeywordsMapList.add(subjectKeywordsMap);
} }
subjectKeywordsMapService.saveBatch(subjectKeywordsMapList); subjectKeywordsMapService.saveBatch(subjectKeywordsMapList);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论