提交 a6a40fad 作者: 925993793@qq.com

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

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