...
|
...
|
@@ -10,6 +10,7 @@ import com.yoho.search.core.es.utils.IgnoreSomeException; |
|
|
import com.yoho.search.service.service.SearchCacheService;
|
|
|
import com.yoho.search.service.service.SearchCommonService;
|
|
|
import com.yoho.search.service.service.SearchDynamicConfigService;
|
|
|
import com.yoho.search.service.service.SearchKeyWordService;
|
|
|
import com.yoho.search.service.servicenew.ISuggestService;
|
|
|
import com.yoho.search.service.utils.HttpServletRequestUtils;
|
|
|
import com.yoho.search.service.utils.SearchRequestParams;
|
...
|
...
|
@@ -58,6 +59,8 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl |
|
|
private SearchCacheService searchCacheService;
|
|
|
@Autowired
|
|
|
private SearchDynamicConfigService searchDynamicConfigService;
|
|
|
@Autowired
|
|
|
private SearchKeyWordService searchKeyWordService;
|
|
|
|
|
|
private ApplicationEventPublisher publisher;
|
|
|
|
...
|
...
|
@@ -290,6 +293,7 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl |
|
|
}
|
|
|
|
|
|
String queryWord = paramMap.get(SearchRequestParams.PARAM_SEARCH_KEYWORD).toLowerCase();
|
|
|
searchKeyWordService.recordSuggestTip(queryWord);
|
|
|
String dest = getSuggestConversionDestBySource(queryWord);
|
|
|
if (StringUtils.isEmpty(dest)) {
|
|
|
return new ArrayList<>();
|
...
|
...
|
@@ -300,7 +304,7 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl |
|
|
List<String> keywordsInDest = Arrays.stream(dest.split(",")).map(String::toLowerCase).map(String::trim).collect(Collectors.toList());
|
|
|
QueryBuilder queryBuilder = QueryBuilders.termsQuery("keyword.keyword_lowercase", keywordsInDest);
|
|
|
FunctionScoreQueryBuilder functionScoreQueryBuilder = new FunctionScoreQueryBuilder(queryBuilder);
|
|
|
functionScoreQueryBuilder.add(QueryBuilders.termQuery("type",2), ScoreFunctionBuilders.weightFactorFunction(keywordsInDest.size()));
|
|
|
functionScoreQueryBuilder.add(QueryBuilders.termQuery("type", 2), ScoreFunctionBuilders.weightFactorFunction(keywordsInDest.size()));
|
|
|
for (int index = 0; index < keywordsInDest.size(); index++) {
|
|
|
// 根据顺序从高到低加分
|
|
|
functionScoreQueryBuilder.add(QueryBuilders.termQuery("keyword.keyword_lowercase", keywordsInDest.get(index)),
|
...
|
...
|
|