...
|
...
|
@@ -2,6 +2,7 @@ package com.yoho.search.service.servicenew.impl; |
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yoho.error.event.SearchEvent;
|
|
|
import com.yoho.search.base.utils.CharUtils;
|
|
|
import com.yoho.search.base.utils.EventReportEnum;
|
|
|
import com.yoho.search.base.utils.ISearchConstants;
|
|
|
import com.yoho.search.core.es.model.SearchParam;
|
...
|
...
|
@@ -285,7 +286,7 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl |
|
|
FunctionScoreQueryBuilder functionScoreQueryBuilder = new FunctionScoreQueryBuilder(QueryBuilders.constantScoreQuery(queryBuilder));
|
|
|
for (String term : termSet) {
|
|
|
// 2.2) 对于完全匹配Term的加1分
|
|
|
functionScoreQueryBuilder.add(QueryBuilders.termQuery("keyword.keyword_lowercase", term.trim().toLowerCase()),
|
|
|
functionScoreQueryBuilder.add(QueryBuilders.termQuery("standardKeyword", CharUtils.standardized(term)),
|
|
|
ScoreFunctionBuilders.weightFactorFunction(1));
|
|
|
|
|
|
// 2.3) 对于匹配到一个Term的加2分
|
...
|
...
|
@@ -300,7 +301,7 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl |
|
|
|
|
|
BoolQueryBuilder boolFilter = QueryBuilders.boolQuery();
|
|
|
boolFilter.must(QueryBuilders.rangeQuery(countField).gte(SMART_SUGGESTION_COUNT_LIMIT));
|
|
|
boolFilter.mustNot(QueryBuilders.termQuery("keyword.keyword_lowercase", queryWord.trim().toLowerCase()));
|
|
|
boolFilter.mustNot(QueryBuilders.termQuery("standardKeyword", CharUtils.standardized(queryWord)));
|
|
|
searchParam.setFiter(boolFilter);
|
|
|
|
|
|
// 2.4) 按照得分、权重、数量的规则降序排序
|
...
|
...
|
@@ -332,7 +333,7 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl |
|
|
logger.info("[func=suggestTipsBySuggestIndex][query={}][cost={}]", queryWord, System.currentTimeMillis() - begin);
|
|
|
return suggestResult;
|
|
|
}
|
|
|
|
|
|
|
|
|
private JSONObject suggestTipsByConversionIndex(Map<String, String> paramMap) {
|
|
|
String queryWord = paramMap.get(SearchRequestParams.PARAM_SEARCH_KEYWORD).toLowerCase();
|
|
|
long begin = System.currentTimeMillis();
|
...
|
...
|
|