Authored by Gino Zhang

Merge branch 'master' into zf_smart_search3

@@ -20,69 +20,92 @@ import com.yoho.search.service.service.SearchDynamicConfigService; @@ -20,69 +20,92 @@ import com.yoho.search.service.service.SearchDynamicConfigService;
20 public class PersonalVectorFeatureSearch { 20 public class PersonalVectorFeatureSearch {
21 21
22 private static final Logger PERSONALIZED = LoggerFactory.getLogger("PERSONALIZED"); 22 private static final Logger PERSONALIZED = LoggerFactory.getLogger("PERSONALIZED");
23 -  
24 private static final Double BASE_CONSTANT = 1.0D; 23 private static final Double BASE_CONSTANT = 1.0D;
25 -  
26 private static final Double FACTOR_CONSTANT = 0.8D; 24 private static final Double FACTOR_CONSTANT = 0.8D;
27 25
28 @Autowired 26 @Autowired
29 private SearchDynamicConfigService searchDynamicConfigService; 27 private SearchDynamicConfigService searchDynamicConfigService;
30 -  
31 @Autowired 28 @Autowired
32 private PersonalizedRedisService personalizedRedisService; 29 private PersonalizedRedisService personalizedRedisService;
33 30
34 - public void addPersonalizedScriptScore(FunctionScoreQueryBuilder functionScoreQueryBuilder, Map<String, String> paramMap) { 31 + private void doAddPersionalFunctionScoreQueryBuilder(FunctionScoreQueryBuilder functionScoreQueryBuilder, String userVectorFeature, String vectorFeatureVersion) {
  32 + Map<String, Object> scriptParams = new HashMap<>();
  33 + scriptParams.put("field", "productFeatureFactor");
  34 + scriptParams.put("userFeatureFactors", userVectorFeature);
  35 + scriptParams.put("vectorFeatureVersion", vectorFeatureVersion);
  36 + scriptParams.put("baseConstant", BASE_CONSTANT);
  37 + scriptParams.put("factorConstant", FACTOR_CONSTANT);
  38 + Script script = new Script("feature_factor_vector_score", ScriptService.ScriptType.INLINE, "native", scriptParams);
  39 + functionScoreQueryBuilder.add(ScoreFunctionBuilders.scriptFunction(script));
  40 + }
  41 +
  42 + /**
  43 + * 通用的个性化打分逻辑
  44 + *
  45 + * @param functionScoreQueryBuilder
  46 + * @param paramMap
  47 + */
  48 + public void addCommonPersonalizedScriptScore(FunctionScoreQueryBuilder functionScoreQueryBuilder, Map<String, String> paramMap) {
35 // 1. 获取特征向量版本(即生成时间,该时间需要与skn的生成时间一致才有意义) 49 // 1. 获取特征向量版本(即生成时间,该时间需要与skn的生成时间一致才有意义)
36 String vectorFeatureVersion = searchDynamicConfigService.personalizedSearchVersion(); 50 String vectorFeatureVersion = searchDynamicConfigService.personalizedSearchVersion();
37 if (StringUtils.isEmpty(vectorFeatureVersion) || "-1".equals(vectorFeatureVersion)) { 51 if (StringUtils.isEmpty(vectorFeatureVersion) || "-1".equals(vectorFeatureVersion)) {
38 return; 52 return;
39 } 53 }
40 -  
41 String uid = paramMap.get("uid"); 54 String uid = paramMap.get("uid");
42 -  
43 // 2. 获取用户的特征向量 55 // 2. 获取用户的特征向量
44 String userVectorFeature = personalizedRedisService.getUserVectorFeature(uid, vectorFeatureVersion); 56 String userVectorFeature = personalizedRedisService.getUserVectorFeature(uid, vectorFeatureVersion);
45 if (StringUtils.isEmpty(userVectorFeature)) { 57 if (StringUtils.isEmpty(userVectorFeature)) {
46 return; 58 return;
47 } 59 }
  60 + PERSONALIZED.info("do common personal search , paramString is [{}]", HttpServletRequestUtils.genParamString(paramMap));
  61 + // 3、添加个性化打分脚本
  62 + this.doAddPersionalFunctionScoreQueryBuilder(functionScoreQueryBuilder, userVectorFeature, vectorFeatureVersion);
  63 + }
48 64
49 - PERSONALIZED.info("do personal search , paramString is [{}]", HttpServletRequestUtils.genParamString(paramMap));  
50 -  
51 - // 3. 传入参数调用脚本  
52 - // field -> productindex索引种保存skn特征向量的字段名  
53 - // userFeatureFactors -> 用户特征向量值,多个值之间用逗号分隔  
54 - // vectorFeatureVersion -> 用户特征向量版本,当与skn的版本一致才计算相关性  
55 - // baseConstant,factorConstant -> 相关性常量和系数,计算规则为 baseConstant +  
56 - // factorConstant * cos(Vuser, Vskn)  
57 - Map<String, Object> scriptParams = new HashMap<>();  
58 - scriptParams.put("field", "productFeatureFactor");  
59 - scriptParams.put("userFeatureFactors", userVectorFeature);  
60 - scriptParams.put("vectorFeatureVersion", vectorFeatureVersion);  
61 - scriptParams.put("baseConstant", BASE_CONSTANT);  
62 - scriptParams.put("factorConstant", FACTOR_CONSTANT);  
63 - Script script = new Script("feature_factor_vector_score", ScriptService.ScriptType.INLINE, "native", scriptParams);  
64 - functionScoreQueryBuilder.add(ScoreFunctionBuilders.scriptFunction(script)); 65 + /**
  66 + * 活动个性化打分逻辑【使用用户购物车、收藏夹的维度】
  67 + *
  68 + * @param functionScoreQueryBuilder
  69 + * @param paramMap
  70 + */
  71 + public void addActivityPersonalizedScriptScore(FunctionScoreQueryBuilder functionScoreQueryBuilder, Map<String, String> paramMap) {
  72 + // 1. 获取特征向量版本(即生成时间,该时间需要与skn的生成时间一致才有意义)
  73 + String vectorFeatureVersion = searchDynamicConfigService.personalizedSearchVersion();
  74 + if (StringUtils.isEmpty(vectorFeatureVersion) || "-1".equals(vectorFeatureVersion)) {
  75 + return;
  76 + }
  77 + String uid = paramMap.get("uid");
  78 + // 2. 获取用户的特征向量
  79 + String userVectorFeature = personalizedRedisService.getUserActivityVectorFeature(uid, vectorFeatureVersion);
  80 + if (StringUtils.isEmpty(userVectorFeature)) {
  81 + userVectorFeature = personalizedRedisService.getUserVectorFeature(uid, vectorFeatureVersion);
  82 + }
  83 + if (StringUtils.isEmpty(userVectorFeature)) {
  84 + return;
  85 + }
  86 + PERSONALIZED.info("do activity personal search , paramString is [{}]", HttpServletRequestUtils.genParamString(paramMap));
  87 + // 3、添加个性化打分脚本
  88 + this.doAddPersionalFunctionScoreQueryBuilder(functionScoreQueryBuilder, userVectorFeature, vectorFeatureVersion);
65 } 89 }
66 90
67 - public void addPersonalizedScriptScoreUserProductFeature(FunctionScoreQueryBuilder functionScoreQueryBuilder, String productVectorFeature) { 91 + /**
  92 + * 直接使用商品特征的个性化打分逻辑
  93 + *
  94 + * @param functionScoreQueryBuilder
  95 + * @param paramMap
  96 + */
  97 + public void addProductPersonalizedScriptScore(FunctionScoreQueryBuilder functionScoreQueryBuilder, String productVectorFeature) {
68 // 1. 获取商品特征向量 98 // 1. 获取商品特征向量
69 - if(StringUtils.isBlank(productVectorFeature)){ 99 + if (StringUtils.isBlank(productVectorFeature)) {
70 return; 100 return;
71 } 101 }
72 // 2. 传入参数调用脚本,以商品特征代替用户特征 102 // 2. 传入参数调用脚本,以商品特征代替用户特征
73 - Map<String, Object> scriptParams = new HashMap<>();  
74 - scriptParams.put("field", "productFeatureFactor");  
75 -  
76 - String [] productVectorFeatures = productVectorFeature.split("\\|",2);  
77 - if(productVectorFeatures.length!=2){ 103 + String[] productVectorFeatures = productVectorFeature.split("\\|", 2);
  104 + if (productVectorFeatures.length != 2) {
78 return; 105 return;
79 } 106 }
80 - scriptParams.put("userFeatureFactors", productVectorFeatures[1]);  
81 - scriptParams.put("vectorFeatureVersion", productVectorFeatures[0]);  
82 - scriptParams.put("baseConstant", BASE_CONSTANT);  
83 - scriptParams.put("factorConstant", FACTOR_CONSTANT);  
84 - Script script = new Script("feature_factor_vector_score", ScriptService.ScriptType.INLINE, "native", scriptParams);  
85 - functionScoreQueryBuilder.add(ScoreFunctionBuilders.scriptFunction(script)); 107 + // 3、添加个性化打分脚本
  108 + this.doAddPersionalFunctionScoreQueryBuilder(functionScoreQueryBuilder, productVectorFeatures[1], productVectorFeatures[0]);
86 } 109 }
87 110
88 /** 111 /**
@@ -172,5 +195,5 @@ public class PersonalVectorFeatureSearch { @@ -172,5 +195,5 @@ public class PersonalVectorFeatureSearch {
172 double finalScore = BASE_CONSTANT + FACTOR_CONSTANT * cosScore; 195 double finalScore = BASE_CONSTANT + FACTOR_CONSTANT * cosScore;
173 return finalScore; 196 return finalScore;
174 } 197 }
175 - 198 +
176 } 199 }
@@ -20,6 +20,8 @@ public class PersonalizedRedisService { @@ -20,6 +20,8 @@ public class PersonalizedRedisService {
20 // 保存用户特征向量的key格式,比如 “1022102:w2v:20170103” 值是一个字符串,各个值之间用逗号分隔 20 // 保存用户特征向量的key格式,比如 “1022102:w2v:20170103” 值是一个字符串,各个值之间用逗号分隔
21 private static final String USER_FEATURE_KEY_TEMPLATE = "%s:w2v:%s"; 21 private static final String USER_FEATURE_KEY_TEMPLATE = "%s:w2v:%s";
22 22
  23 + private static final String USER_ACTIVITY_FEATURE_KEY_TEMPLATE = "%s:w2v_f:%s";//活动相关的向量空间【购物车、收藏夹】
  24 +
23 private static final String USER_GENDER_KEY= "%s:gender"; 25 private static final String USER_GENDER_KEY= "%s:gender";
24 26
25 @Autowired 27 @Autowired
@@ -30,6 +32,11 @@ public class PersonalizedRedisService { @@ -30,6 +32,11 @@ public class PersonalizedRedisService {
30 return bigDataRedisOper.getValue(key); 32 return bigDataRedisOper.getValue(key);
31 } 33 }
32 34
  35 + public String getUserActivityVectorFeature(String uid, String generateDate) {
  36 + String key = String.format(USER_ACTIVITY_FEATURE_KEY_TEMPLATE, uid, generateDate);
  37 + return bigDataRedisOper.getValue(key);
  38 + }
  39 +
33 /** 40 /**
34 * 获取用户性别维度 41 * 获取用户性别维度
35 * @param uid 42 * @param uid
@@ -60,7 +60,7 @@ public class FunctionScoreSearchHelper { @@ -60,7 +60,7 @@ public class FunctionScoreSearchHelper {
60 } 60 }
61 // 个性化搜索相关 61 // 个性化搜索相关
62 if (searchCommonHelper.isNeedPersonalSearch(paramMap)) { 62 if (searchCommonHelper.isNeedPersonalSearch(paramMap)) {
63 - this.addPersonalizedScriptScore(functionScoreQueryBuilder, paramMap); 63 + this.addCommonPersonalizedScriptScore(functionScoreQueryBuilder, paramMap);
64 } 64 }
65 // 针对全球购降分 65 // 针对全球购降分
66 if (searchCommonHelper.containGlobal(paramMap)) { 66 if (searchCommonHelper.containGlobal(paramMap)) {
@@ -87,15 +87,19 @@ public class FunctionScoreSearchHelper { @@ -87,15 +87,19 @@ public class FunctionScoreSearchHelper {
87 * @param functionScoreQueryBuilder 87 * @param functionScoreQueryBuilder
88 * @param paramMap 88 * @param paramMap
89 */ 89 */
90 - public void addPersonalizedScriptScore(FunctionScoreQueryBuilder functionScoreQueryBuilder, Map<String, String> paramMap) { 90 + public void addCommonPersonalizedScriptScore(FunctionScoreQueryBuilder functionScoreQueryBuilder, Map<String, String> paramMap) {
91 // 个性化搜索相关 91 // 个性化搜索相关
92 - personalVectorFeatureSearch.addPersonalizedScriptScore(functionScoreQueryBuilder, paramMap); 92 + personalVectorFeatureSearch.addCommonPersonalizedScriptScore(functionScoreQueryBuilder, paramMap);
93 if (searchCommonHelper.isNewRecPageDefault(paramMap)) { 93 if (searchCommonHelper.isNewRecPageDefault(paramMap)) {
94 this.addFirstShelveTimeScore(functionScoreQueryBuilder, newRecShelveTimeScore); 94 this.addFirstShelveTimeScore(functionScoreQueryBuilder, newRecShelveTimeScore);
95 } else { 95 } else {
96 this.addFirstShelveTimeScore(functionScoreQueryBuilder, commonFirstShelveTimeScore); 96 this.addFirstShelveTimeScore(functionScoreQueryBuilder, commonFirstShelveTimeScore);
97 } 97 }
98 } 98 }
  99 +
  100 + public void addActivityPersonalizedScriptScore(FunctionScoreQueryBuilder functionScoreQueryBuilder, Map<String, String> paramMap) {
  101 + personalVectorFeatureSearch.addActivityPersonalizedScriptScore(functionScoreQueryBuilder, paramMap);
  102 + }
99 103
100 private void addFirstShelveTimeScore(FunctionScoreQueryBuilder functionScoreQueryBuilder, FirstShelveTimeScore firstShelveTimeScore) { 104 private void addFirstShelveTimeScore(FunctionScoreQueryBuilder functionScoreQueryBuilder, FirstShelveTimeScore firstShelveTimeScore) {
101 int todayLastSecond = DateUtil.getLastTimeSecond(new Date()); 105 int todayLastSecond = DateUtil.getLastTimeSecond(new Date());
@@ -116,7 +120,7 @@ public class FunctionScoreSearchHelper { @@ -116,7 +120,7 @@ public class FunctionScoreSearchHelper {
116 */ 120 */
117 public QueryBuilder buildFunctionScoreQueryBuildWithProductFeature(QueryBuilder queryBuilder, String productFeature) { 121 public QueryBuilder buildFunctionScoreQueryBuildWithProductFeature(QueryBuilder queryBuilder, String productFeature) {
118 FunctionScoreQueryBuilder functionScoreQueryBuilder = new FunctionScoreQueryBuilder(queryBuilder); 122 FunctionScoreQueryBuilder functionScoreQueryBuilder = new FunctionScoreQueryBuilder(queryBuilder);
119 - personalVectorFeatureSearch.addPersonalizedScriptScoreUserProductFeature(functionScoreQueryBuilder, productFeature); 123 + personalVectorFeatureSearch.addProductPersonalizedScriptScore(functionScoreQueryBuilder, productFeature);
120 return functionScoreQueryBuilder; 124 return functionScoreQueryBuilder;
121 } 125 }
122 126
@@ -11,6 +11,9 @@ import java.util.Map; @@ -11,6 +11,9 @@ import java.util.Map;
11 import javax.annotation.PostConstruct; 11 import javax.annotation.PostConstruct;
12 12
13 import org.apache.commons.lang.StringUtils; 13 import org.apache.commons.lang.StringUtils;
  14 +import org.elasticsearch.index.query.QueryBuilder;
  15 +import org.elasticsearch.index.query.QueryBuilders;
  16 +import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder;
14 import org.elasticsearch.search.SearchHit; 17 import org.elasticsearch.search.SearchHit;
15 import org.elasticsearch.search.SearchHits; 18 import org.elasticsearch.search.SearchHits;
16 import org.elasticsearch.search.aggregations.AbstractAggregationBuilder; 19 import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
@@ -40,6 +43,7 @@ import com.yoho.search.core.es.utils.IgnoreSomeException; @@ -40,6 +43,7 @@ import com.yoho.search.core.es.utils.IgnoreSomeException;
40 import com.yoho.search.service.service.AggregationService; 43 import com.yoho.search.service.service.AggregationService;
41 import com.yoho.search.service.service.SearchCacheService; 44 import com.yoho.search.service.service.SearchCacheService;
42 import com.yoho.search.service.service.SearchCommonService; 45 import com.yoho.search.service.service.SearchCommonService;
  46 +import com.yoho.search.service.service.helper.FunctionScoreSearchHelper;
43 import com.yoho.search.service.service.helper.SearchCommonHelper; 47 import com.yoho.search.service.service.helper.SearchCommonHelper;
44 import com.yoho.search.service.service.helper.SearchServiceHelper; 48 import com.yoho.search.service.service.helper.SearchServiceHelper;
45 import com.yoho.search.service.service.helper.SearchSortHelper; 49 import com.yoho.search.service.service.helper.SearchSortHelper;
@@ -64,6 +68,8 @@ public class AggProductListServiceImpl implements IAggProductListService, Applic @@ -64,6 +68,8 @@ public class AggProductListServiceImpl implements IAggProductListService, Applic
64 private SearchCommonService searchCommonService; 68 private SearchCommonService searchCommonService;
65 @Autowired 69 @Autowired
66 private SearchCacheService searchCacheService; 70 private SearchCacheService searchCacheService;
  71 + @Autowired
  72 + private FunctionScoreSearchHelper functionScoreSearchHelper;
67 73
68 private ApplicationEventPublisher publisher; 74 private ApplicationEventPublisher publisher;
69 75
@@ -81,6 +87,12 @@ public class AggProductListServiceImpl implements IAggProductListService, Applic @@ -81,6 +87,12 @@ public class AggProductListServiceImpl implements IAggProductListService, Applic
81 aggTypeToEsField.put("sort", "smallSortId"); 87 aggTypeToEsField.put("sort", "smallSortId");
82 aggTypeToEsField.put("brand", "brandId"); 88 aggTypeToEsField.put("brand", "brandId");
83 } 89 }
  90 +
  91 + private QueryBuilder builderActivityQueryBuilder(Map<String, String> paramMap) {
  92 + FunctionScoreQueryBuilder functionScoreQueryBuilder = new FunctionScoreQueryBuilder(QueryBuilders.matchAllQuery());
  93 + functionScoreSearchHelper.addActivityPersonalizedScriptScore(functionScoreQueryBuilder, paramMap);
  94 + return functionScoreQueryBuilder;
  95 + }
84 96
85 @Override 97 @Override
86 public SearchApiResult aggProductList(Map<String, String> paramMap) { 98 public SearchApiResult aggProductList(Map<String, String> paramMap) {
@@ -103,7 +115,7 @@ public class AggProductListServiceImpl implements IAggProductListService, Applic @@ -103,7 +115,7 @@ public class AggProductListServiceImpl implements IAggProductListService, Applic
103 115
104 // 3、构造查询条件 116 // 3、构造查询条件
105 SearchParam searchParam = new SearchParam(); 117 SearchParam searchParam = new SearchParam();
106 - searchParam.setQuery(searchServiceHelper.constructQueryBuilderForProductList(paramMap));// 支持个性化 118 + searchParam.setQuery(this.builderActivityQueryBuilder(paramMap));// 活动特定的个性化
107 searchParam.setFiter(searchServiceHelper.constructFilterBuilder(paramMap, null)); 119 searchParam.setFiter(searchServiceHelper.constructFilterBuilder(paramMap, null));
108 searchParam.setSize(0); 120 searchParam.setSize(0);
109 121
@@ -201,7 +213,7 @@ public class AggProductListServiceImpl implements IAggProductListService, Applic @@ -201,7 +213,7 @@ public class AggProductListServiceImpl implements IAggProductListService, Applic
201 } 213 }
202 // 3、构造查询条件 214 // 3、构造查询条件
203 SearchParam searchParam = new SearchParam(); 215 SearchParam searchParam = new SearchParam();
204 - searchParam.setQuery(searchServiceHelper.constructQueryBuilderForProductList(paramMap));// 支持个性化 216 + searchParam.setQuery(this.builderActivityQueryBuilder(paramMap));// 活动特定的个性化
205 searchParam.setFiter(searchServiceHelper.constructFilterBuilder(paramMap, null)); 217 searchParam.setFiter(searchServiceHelper.constructFilterBuilder(paramMap, null));
206 searchParam.setSize(0); 218 searchParam.setSize(0);
207 219
@@ -218,7 +230,7 @@ public class AggProductListServiceImpl implements IAggProductListService, Applic @@ -218,7 +230,7 @@ public class AggProductListServiceImpl implements IAggProductListService, Applic
218 List<AbstractAggregationBuilder> list = new ArrayList<AbstractAggregationBuilder>(); 230 List<AbstractAggregationBuilder> list = new ArrayList<AbstractAggregationBuilder>();
219 // 4.1)构造父聚合:品牌或品类聚合【同时按子聚合的sort字段排序】 231 // 4.1)构造父聚合:品牌或品类聚合【同时按子聚合的sort字段排序】
220 TermsBuilder brandAggregationBuilder = AggregationBuilders.terms(firstAggName).field("brandId").order(Terms.Order.aggregation("sort", sortOrder.equals(SortOrder.ASC))) 232 TermsBuilder brandAggregationBuilder = AggregationBuilders.terms(firstAggName).field("brandId").order(Terms.Order.aggregation("sort", sortOrder.equals(SortOrder.ASC)))
221 - .size(200+pageSize); 233 + .size(200 + pageSize);
222 // 4.2)添加子聚合:取得分最大的值 234 // 4.2)添加子聚合:取得分最大的值
223 brandAggregationBuilder.subAggregation(AggregationBuilders.max("sort").field(sortField)); 235 brandAggregationBuilder.subAggregation(AggregationBuilders.max("sort").field(sortField));
224 // 4.3)添加孙聚合:取打分最高的一个product 236 // 4.3)添加孙聚合:取打分最高的一个product
@@ -244,7 +256,7 @@ public class AggProductListServiceImpl implements IAggProductListService, Applic @@ -244,7 +256,7 @@ public class AggProductListServiceImpl implements IAggProductListService, Applic
244 if (!aggMaps.containsKey(firstAggName)) { 256 if (!aggMaps.containsKey(firstAggName)) {
245 return searchApiResult.setData(""); 257 return searchApiResult.setData("");
246 } 258 }
247 - List<Map<String, Object>> productList = this.getProductListOrderByScore(((MultiBucketsAggregation) aggMaps.get(firstAggName)), pageSize,sortField,sortOrder); 259 + List<Map<String, Object>> productList = this.getProductListOrderByScore(((MultiBucketsAggregation) aggMaps.get(firstAggName)), pageSize, sortField, sortOrder);
248 jsonObject = new JSONObject(); 260 jsonObject = new JSONObject();
249 jsonObject.put("total", pageSize); 261 jsonObject.put("total", pageSize);
250 jsonObject.put("page", 1); 262 jsonObject.put("page", 1);
@@ -302,19 +314,19 @@ public class AggProductListServiceImpl implements IAggProductListService, Applic @@ -302,19 +314,19 @@ public class AggProductListServiceImpl implements IAggProductListService, Applic
302 if (value == null) { 314 if (value == null) {
303 return 0; 315 return 0;
304 } 316 }
305 - if (value instanceof Float){ 317 + if (value instanceof Float) {
306 return ((Float) value).floatValue(); 318 return ((Float) value).floatValue();
307 } 319 }
308 - if (value instanceof Integer){ 320 + if (value instanceof Integer) {
309 return ((Integer) value); 321 return ((Integer) value);
310 } 322 }
311 - if (value instanceof Long){ 323 + if (value instanceof Long) {
312 return ((Long) value); 324 return ((Long) value);
313 } 325 }
314 - if (value instanceof String){ 326 + if (value instanceof String) {
315 return Double.valueOf(value.toString()); 327 return Double.valueOf(value.toString());
316 } 328 }
317 - if (value instanceof Double){ 329 + if (value instanceof Double) {
318 return Double.valueOf(value.toString()); 330 return Double.valueOf(value.toString());
319 } 331 }
320 return 0; 332 return 0;
@@ -142,7 +142,7 @@ public class GoodProductListService implements IGoodProductsService { @@ -142,7 +142,7 @@ public class GoodProductListService implements IGoodProductsService {
142 } 142 }
143 // 加上个性化打分 143 // 加上个性化打分
144 if (searchCommonHelper.isNeedPersonalSearch(paramMap)) { 144 if (searchCommonHelper.isNeedPersonalSearch(paramMap)) {
145 - functionScoreSearchHelper.addPersonalizedScriptScore(functionScoreQueryBuilder, paramMap); 145 + functionScoreSearchHelper.addCommonPersonalizedScriptScore(functionScoreQueryBuilder, paramMap);
146 } 146 }
147 return functionScoreQueryBuilder; 147 return functionScoreQueryBuilder;
148 } 148 }
@@ -244,7 +244,7 @@ public class GoodProductListService implements IGoodProductsService { @@ -244,7 +244,7 @@ public class GoodProductListService implements IGoodProductsService {
244 functionScoreQueryBuilder.add(QueryBuilders.termsQuery("productSkn", productSkns.split(",")), ScoreFunctionBuilders.weightFactorFunction(100)); 244 functionScoreQueryBuilder.add(QueryBuilders.termsQuery("productSkn", productSkns.split(",")), ScoreFunctionBuilders.weightFactorFunction(100));
245 } 245 }
246 // 强制加上个性化打分 246 // 强制加上个性化打分
247 - functionScoreSearchHelper.addPersonalizedScriptScore(functionScoreQueryBuilder, paramMap); 247 + functionScoreSearchHelper.addCommonPersonalizedScriptScore(functionScoreQueryBuilder, paramMap);
248 searchParam.setQuery(functionScoreQueryBuilder); 248 searchParam.setQuery(functionScoreQueryBuilder);
249 249
250 // 4、设置聚合条件 250 // 4、设置聚合条件