1.fix full text fuzzy search for case '西安独立音乐合辑2–废城甜梦'

main
Gary 5 months ago
parent d8f5331e9b
commit 1b41cf2ee0

@ -23,6 +23,8 @@ import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import util.StringTools;
import com.luoo.music.dao.CommentDao;
@ -297,7 +299,11 @@ public class JournalService {
if(keyword.length()==1) {
return searchByLike(keyword,pageRequest);
}
return journalDao.fuzzySearch("+\""+keyword+"\"", pageRequest.getPageNumber()*pageRequest.getPageSize(), pageRequest.getPageSize());
List<Journal> fullTextFuzzySearchResults = journalDao.fuzzySearch("+\""+keyword+"\"", pageRequest.getPageNumber()*pageRequest.getPageSize(), pageRequest.getPageSize());
if(CollectionUtils.isEmpty(fullTextFuzzySearchResults)) {
return searchByLike(keyword, pageRequest);
}
return fullTextFuzzySearchResults;
}
public static boolean isNumeric(String str){

@ -12,6 +12,8 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
@ -144,7 +146,11 @@ public class JournalSongService {
if(keyword.length()==1) {
return searchByLike(keyword,pageRequest);
}
return journalSongDao.fuzzySearch("+\""+keyword+"\"", pageRequest.getPageNumber()*pageRequest.getPageSize(), pageRequest.getPageSize());
List<JournalSong> fullTextFuzzySearchResults = journalSongDao.fuzzySearch("+\""+keyword+"\"", pageRequest.getPageNumber()*pageRequest.getPageSize(), pageRequest.getPageSize());
if(CollectionUtils.isEmpty(fullTextFuzzySearchResults)) {
return searchByLike(keyword, pageRequest);
}
return fullTextFuzzySearchResults;
}
private List<JournalSong> searchByLike(String keyword, PageRequest pageRequest) {

Loading…
Cancel
Save