|
@ -13,6 +13,8 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@ -21,6 +23,8 @@ public class ProfileSearchService extends BaseJpaService<HotWord,HotWordDao> {
|
|
|
|
|
|
private static final String PrefixRedis = "HOTWORDS_";
|
|
private static final String PrefixRedis = "HOTWORDS_";
|
|
|
|
|
|
|
|
private static final Pattern p = Pattern.compile("\"(.*?)\"");//正则提取引号的内容
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private RedisTemplate redisTemplate;
|
|
private RedisTemplate redisTemplate;
|
|
@Autowired
|
|
@Autowired
|
|
@ -68,6 +72,13 @@ public class ProfileSearchService extends BaseJpaService<HotWord,HotWordDao> {
|
|
private List<String> getSearchKeyWords(String keys){
|
|
private List<String> getSearchKeyWords(String keys){
|
|
List<String> list = new ArrayList<>();
|
|
List<String> list = new ArrayList<>();
|
|
if(StringUtils.isNotBlank(keys)){
|
|
if(StringUtils.isNotBlank(keys)){
|
|
|
|
Matcher m = p.matcher(keys);
|
|
|
|
while(m.find()){
|
|
|
|
list.add(m.group());
|
|
|
|
}
|
|
|
|
for(String key:list){
|
|
|
|
keys = keys.replace(key,"");
|
|
|
|
}
|
|
String[] keyArray = keys.split(" ");
|
|
String[] keyArray = keys.split(" ");
|
|
for(String key:keyArray){
|
|
for(String key:keyArray){
|
|
if(StringUtils.isNotBlank(key) && !"or".equalsIgnoreCase(key) && !"and".equalsIgnoreCase(key)){
|
|
if(StringUtils.isNotBlank(key) && !"or".equalsIgnoreCase(key) && !"and".equalsIgnoreCase(key)){
|