Authored by hugufei

品牌向量+品类向量开发

@@ -28,8 +28,11 @@ public class SortBrandRecallRequestBuilder { @@ -28,8 +28,11 @@ public class SortBrandRecallRequestBuilder {
28 * @return 28 * @return
29 */ 29 */
30 public List<RecallRequest> buildSortBrandRecallRequests(int uid, ParamQueryFilter paramQueryFilter, List<SortBrand> sortBrands, SortBrandType sortBrandType, int recallSknCount) { 30 public List<RecallRequest> buildSortBrandRecallRequests(int uid, ParamQueryFilter paramQueryFilter, List<SortBrand> sortBrands, SortBrandType sortBrandType, int recallSknCount) {
31 - //1、构造召回请求  
32 List<RecallRequest> requests = new ArrayList<>(); 31 List<RecallRequest> requests = new ArrayList<>();
  32 + // 0)、参数判断
  33 + if(sortBrands==null || sortBrands.isEmpty()){
  34 + return requests;
  35 + }
33 // 1) 人气 36 // 1) 人气
34 for (SortBrand sortBrand : sortBrands) { 37 for (SortBrand sortBrand : sortBrands) {
35 requests.add(this.buildSortBrandHeatValueRequest(paramQueryFilter, sortBrand, recallSknCount, sortBrandType)); 38 requests.add(this.buildSortBrandHeatValueRequest(paramQueryFilter, sortBrand, recallSknCount, sortBrandType));
1 package com.yoho.search.recall.scene.beans.cache; 1 package com.yoho.search.recall.scene.beans.cache;
2 2
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 -import com.yoho.search.base.utils.CollectionUtils;  
5 -import com.yoho.search.core.personalized.models.SortBrand;  
6 -import com.yoho.search.models.SearchApiResult;  
7 import com.yoho.search.recall.scene.beans.builder.*; 4 import com.yoho.search.recall.scene.beans.builder.*;
8 import com.yoho.search.recall.scene.beans.persional.QueryUserPersionalFactorBean; 5 import com.yoho.search.recall.scene.beans.persional.QueryUserPersionalFactorBean;
9 import com.yoho.search.recall.scene.beans.strategy.SortBrandType; 6 import com.yoho.search.recall.scene.beans.strategy.SortBrandType;
10 -import com.yoho.search.recall.scene.beans.strategy.impls.RecommendSknStrategy;  
11 import com.yoho.search.recall.scene.constants.SknCountConstants; 7 import com.yoho.search.recall.scene.constants.SknCountConstants;
12 import com.yoho.search.recall.scene.models.common.RecallMergerResult; 8 import com.yoho.search.recall.scene.models.common.RecallMergerResult;
13 import com.yoho.search.recall.scene.models.personal.UserPersonalFactor; 9 import com.yoho.search.recall.scene.models.personal.UserPersonalFactor;
14 import com.yoho.search.recall.scene.models.req.*; 10 import com.yoho.search.recall.scene.models.req.*;
15 -import com.yoho.search.service.base.SearchDynamicConfigService;  
16 import org.slf4j.Logger; 11 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory; 12 import org.slf4j.LoggerFactory;
18 import org.springframework.beans.factory.annotation.Autowired; 13 import org.springframework.beans.factory.annotation.Autowired;
@@ -43,7 +38,7 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us @@ -43,7 +38,7 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us
43 @Autowired 38 @Autowired
44 private UserRecallResponseBuilder userRecallResponseBuilder; 39 private UserRecallResponseBuilder userRecallResponseBuilder;
45 40
46 - private ExecutorService recallExecutorService = Executors.newFixedThreadPool(30); 41 + private ExecutorService recallExecutorService = Executors.newFixedThreadPool(50);
47 42
48 /** 43 /**
49 * 召回入口 44 * 召回入口
@@ -105,7 +100,7 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us @@ -105,7 +100,7 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us
105 private List<RecallRequestResponse> batchRecall(UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) { 100 private List<RecallRequestResponse> batchRecall(UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) {
106 101
107 //1、处理实时推荐SKN的召回 102 //1、处理实时推荐SKN的召回
108 - CompletableFuture<List<RecallRequestResponse>> recallBySknListCompletableFuture = this.doRecallBySknList(userRecallRequest, userPersonalFactor); 103 + CompletableFuture<List<RecallRequestResponse>> sknListCompletableFuture = this.doRecallSknList(userRecallRequest, userPersonalFactor);
109 104
110 //2、处理通用召回 105 //2、处理通用召回
111 CompletableFuture<List<RecallRequestResponse>> commonCompletableFuture = this.doRecallCommon(userRecallRequest, userPersonalFactor); 106 CompletableFuture<List<RecallRequestResponse>> commonCompletableFuture = this.doRecallCommon(userRecallRequest, userPersonalFactor);
@@ -113,22 +108,26 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us @@ -113,22 +108,26 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us
113 //3、处理实时推荐的品类品牌的召回 108 //3、处理实时推荐的品类品牌的召回
114 CompletableFuture<List<RecallRequestResponse>> realTimeSortBrandCompletableFuture = this.doRecallRealTimeSortBrand(userRecallRequest, userPersonalFactor); 109 CompletableFuture<List<RecallRequestResponse>> realTimeSortBrandCompletableFuture = this.doRecallRealTimeSortBrand(userRecallRequest, userPersonalFactor);
115 110
116 - //4、处理基于向量生成的品类品牌的召回  
117 - CompletableFuture<List<RecallRequestResponse>> vectorSortBrandCompletableFuture = this.doRecallVectorSortBrand(userRecallRequest, userPersonalFactor);  
118 -  
119 - //5、处理RNN预测的品类品牌的召回 111 + //4、处理预测的品类品牌的召回
120 CompletableFuture<List<RecallRequestResponse>> forecastSortBrandCompletableFuture = this.doRecallPredictSortBrand(userRecallRequest, userPersonalFactor); 112 CompletableFuture<List<RecallRequestResponse>> forecastSortBrandCompletableFuture = this.doRecallPredictSortBrand(userRecallRequest, userPersonalFactor);
121 113
122 - //6、构造最终返回结果投入额 114 + //5、处理基于RNN向量生成的品类品牌的召回
  115 + CompletableFuture<List<RecallRequestResponse>> vectorRnnSortBrandCompletableFuture = this.doRecallVectorRnnSortBrand(userRecallRequest, userPersonalFactor);
  116 +
  117 + //7、处理基于W2V向量生成的品类品牌的召回
  118 + CompletableFuture<List<RecallRequestResponse>> vectorW2vSortBrandCompletableFuture = this.doRecallVectorW2vSortBrand(userRecallRequest, userPersonalFactor);
  119 +
  120 + //8、构造最终返回结果投入额
123 List<RecallRequestResponse> batchRequestResults = new ArrayList<>(); 121 List<RecallRequestResponse> batchRequestResults = new ArrayList<>();
124 122
125 - batchRequestResults.addAll(this.getResultFromCompletableFuture(recallBySknListCompletableFuture));//按skn召回放在第一个,不然merger的时候可能会无序 123 + batchRequestResults.addAll(this.getResultFromCompletableFuture(sknListCompletableFuture));//按skn召回放在第一个,不然merger的时候可能会无序
126 batchRequestResults.addAll(this.getResultFromCompletableFuture(commonCompletableFuture)); 124 batchRequestResults.addAll(this.getResultFromCompletableFuture(commonCompletableFuture));
127 batchRequestResults.addAll(this.getResultFromCompletableFuture(realTimeSortBrandCompletableFuture)); 125 batchRequestResults.addAll(this.getResultFromCompletableFuture(realTimeSortBrandCompletableFuture));
128 - batchRequestResults.addAll(this.getResultFromCompletableFuture(vectorSortBrandCompletableFuture));  
129 batchRequestResults.addAll(this.getResultFromCompletableFuture(forecastSortBrandCompletableFuture)); 126 batchRequestResults.addAll(this.getResultFromCompletableFuture(forecastSortBrandCompletableFuture));
  127 + batchRequestResults.addAll(this.getResultFromCompletableFuture(vectorRnnSortBrandCompletableFuture));
  128 + batchRequestResults.addAll(this.getResultFromCompletableFuture(vectorW2vSortBrandCompletableFuture));
130 129
131 - //6、日志打印 130 + //9、日志打印
132 if (userRecallRequest.openDetailLog()) { 131 if (userRecallRequest.openDetailLog()) {
133 for (RecallRequestResponse recallRequestResponse : batchRequestResults) { 132 for (RecallRequestResponse recallRequestResponse : batchRequestResults) {
134 RecallRequest recallRequest = recallRequestResponse.getRequest(); 133 RecallRequest recallRequest = recallRequestResponse.getRequest();
@@ -174,12 +173,11 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us @@ -174,12 +173,11 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us
174 * @param userPersonalFactor 173 * @param userPersonalFactor
175 * @return 174 * @return
176 */ 175 */
177 - private CompletableFuture<List<RecallRequestResponse>> doRecallBySknList(UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) { 176 + private CompletableFuture<List<RecallRequestResponse>> doRecallSknList(UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) {
178 return CompletableFuture.supplyAsync(() -> { 177 return CompletableFuture.supplyAsync(() -> {
179 long begin = System.currentTimeMillis(); 178 long begin = System.currentTimeMillis();
180 - int recommendSknCount = userPersonalFactor.getRecommendSknList() == null ? 0 : userPersonalFactor.getRecommendSknList().size();  
181 List<RecallRequestResponse> recommendSknRequestResponses = sknRecallCacheBean.batchRecallBySknList(userRecallRequest, userPersonalFactor, SknCountConstants.REC_SKN_COUNT); 179 List<RecallRequestResponse> recommendSknRequestResponses = sknRecallCacheBean.batchRecallBySknList(userRecallRequest, userPersonalFactor, SknCountConstants.REC_SKN_COUNT);
182 - RECALL_NEW_LOGGER.info("UserRecallCacheBean[2.2]-doRecallRecommendSkn,recommendSknCount is [{}],cost is [{}]", recommendSknCount, System.currentTimeMillis() - begin); 180 + RECALL_NEW_LOGGER.info("UserRecallCacheBean[2.2]-doRecallRecommendSkn,recommendSknCount is [{}],cost is [{}]", recommendSknRequestResponses.size(), System.currentTimeMillis() - begin);
183 return recommendSknRequestResponses; 181 return recommendSknRequestResponses;
184 }, recallExecutorService); 182 }, recallExecutorService);
185 } 183 }
@@ -202,36 +200,54 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us @@ -202,36 +200,54 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us
202 } 200 }
203 201
204 /** 202 /**
205 - * 执行向量【品牌+品类】的召回 203 + * 执行预测【品牌+品类】的召回
  204 + *
  205 + * @param userRecallRequest
  206 + * @param userPersonalFactor
  207 + * @return
  208 + */
  209 + private CompletableFuture<List<RecallRequestResponse>> doRecallPredictSortBrand(UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) {
  210 + return CompletableFuture.supplyAsync(() -> {
  211 + long begin = System.currentTimeMillis();
  212 + List<RecallRequest> forecastSortBrandRequests = sortBrandRecallRequestBuilder.buildSortBrandRecallRequests(userRecallRequest.getUid(), userRecallRequest.getParamQueryFilter(), userPersonalFactor.getPredictSortBrandList(), SortBrandType.PRED_SORT_BRAND, SknCountConstants.PRED_SORT_BRAND_SKN_COUNT);
  213 + List<RecallRequestResponse> forecastSortBrandRequestsResponses = batchRecallCacheBean.batchRecallAndCache(forecastSortBrandRequests);
  214 + RECALL_NEW_LOGGER.info("UserRecallCacheBean[2.4]-doRecallPredictSortBrand,requestCount is [{}], cost is [{}]", forecastSortBrandRequests.size(), System.currentTimeMillis() - begin);
  215 + return forecastSortBrandRequestsResponses;
  216 + }, recallExecutorService);
  217 + }
  218 +
  219 +
  220 + /**
  221 + * 执行RNN向量【品牌+品类】的召回
206 * 222 *
207 * @param userRecallRequest 223 * @param userRecallRequest
208 * @param userPersonalFactor 224 * @param userPersonalFactor
209 * @return 225 * @return
210 */ 226 */
211 - private CompletableFuture<List<RecallRequestResponse>> doRecallVectorSortBrand(UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) { 227 + private CompletableFuture<List<RecallRequestResponse>> doRecallVectorRnnSortBrand(UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) {
212 return CompletableFuture.supplyAsync(() -> { 228 return CompletableFuture.supplyAsync(() -> {
213 long begin = System.currentTimeMillis(); 229 long begin = System.currentTimeMillis();
214 - List<RecallRequest> vecortSortBrandRequests = sortBrandRecallRequestBuilder.buildSortBrandRecallRequests(userRecallRequest.getUid(), userRecallRequest.getParamQueryFilter(), userPersonalFactor.getVectorSortBrandList(), SortBrandType.VEC_SORT_BRAND, SknCountConstants.VEC_SORT_BRAND_SKN_COUNT);  
215 - List<RecallRequestResponse> vecSortBrandRequestsResponses = batchRecallCacheBean.batchRecallAndCache(vecortSortBrandRequests);  
216 - RECALL_NEW_LOGGER.info("UserRecallCacheBean[2.4]-doRecallVectorSortBrand,requestCount is [{}], cost is [{}]", vecortSortBrandRequests.size(), System.currentTimeMillis() - begin); 230 + List<RecallRequest> vectorRnnSortBrandRequests = sortBrandRecallRequestBuilder.buildSortBrandRecallRequests(userRecallRequest.getUid(), userRecallRequest.getParamQueryFilter(), userPersonalFactor.getVectorRnnSortBrandList(), SortBrandType.VEC_RNN_SORT_BRAND, SknCountConstants.VEC_SORT_BRAND_SKN_COUNT);
  231 + List<RecallRequestResponse> vecSortBrandRequestsResponses = batchRecallCacheBean.batchRecallAndCache(vectorRnnSortBrandRequests);
  232 + RECALL_NEW_LOGGER.info("UserRecallCacheBean[2.5]-doRecallVectorRnnSortBrand,requestCount is [{}], cost is [{}]", vectorRnnSortBrandRequests.size(), System.currentTimeMillis() - begin);
217 return vecSortBrandRequestsResponses; 233 return vecSortBrandRequestsResponses;
218 }, recallExecutorService); 234 }, recallExecutorService);
219 } 235 }
220 236
221 /** 237 /**
222 - * 执行预测【品牌+品类】的召回 238 + * 执行w2v向量【品牌+品类】的召回
223 * 239 *
224 * @param userRecallRequest 240 * @param userRecallRequest
225 * @param userPersonalFactor 241 * @param userPersonalFactor
226 * @return 242 * @return
227 */ 243 */
228 - private CompletableFuture<List<RecallRequestResponse>> doRecallPredictSortBrand(UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) { 244 + private CompletableFuture<List<RecallRequestResponse>> doRecallVectorW2vSortBrand(UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) {
229 return CompletableFuture.supplyAsync(() -> { 245 return CompletableFuture.supplyAsync(() -> {
230 long begin = System.currentTimeMillis(); 246 long begin = System.currentTimeMillis();
231 - List<RecallRequest> forecastSortBrandRequests = sortBrandRecallRequestBuilder.buildSortBrandRecallRequests(userRecallRequest.getUid(), userRecallRequest.getParamQueryFilter(), userPersonalFactor.getPredictSortBrandList(), SortBrandType.PRED_SORT_BRAND, SknCountConstants.PRED_SORT_BRAND_SKN_COUNT);  
232 - List<RecallRequestResponse> forecastSortBrandRequestsResponses = batchRecallCacheBean.batchRecallAndCache(forecastSortBrandRequests);  
233 - RECALL_NEW_LOGGER.info("UserRecallCacheBean[2.5]-doRecallPredictSortBrand,requestCount is [{}], cost is [{}]", forecastSortBrandRequests.size(), System.currentTimeMillis() - begin);  
234 - return forecastSortBrandRequestsResponses; 247 + List<RecallRequest> vectorW2vSortBrandRequests = sortBrandRecallRequestBuilder.buildSortBrandRecallRequests(userRecallRequest.getUid(), userRecallRequest.getParamQueryFilter(), userPersonalFactor.getVectorW2vSortBrandList(), SortBrandType.VEC_W2V_SORT_BRAND, SknCountConstants.VEC_SORT_BRAND_SKN_COUNT);
  248 + List<RecallRequestResponse> vecSortBrandRequestsResponses = batchRecallCacheBean.batchRecallAndCache(vectorW2vSortBrandRequests);
  249 + RECALL_NEW_LOGGER.info("UserRecallCacheBean[2.6]-doRecallVectorW2vSortBrand,requestCount is [{}], cost is [{}]", vectorW2vSortBrandRequests.size(), System.currentTimeMillis() - begin);
  250 + return vecSortBrandRequestsResponses;
235 }, recallExecutorService); 251 }, recallExecutorService);
236 } 252 }
237 253
@@ -31,17 +31,18 @@ public class PagePersionalFactorComponent extends AbstractPageComponent<PagePers @@ -31,17 +31,18 @@ public class PagePersionalFactorComponent extends AbstractPageComponent<PagePers
31 31
32 /** 32 /**
33 * 查询个性化因子 33 * 查询个性化因子
  34 + *
34 * @param paramQueryFilter 35 * @param paramQueryFilter
35 * @return 36 * @return
36 */ 37 */
37 public PagePersonalFactor queryPagePersionalFactor(ParamQueryFilter paramQueryFilter) { 38 public PagePersonalFactor queryPagePersionalFactor(ParamQueryFilter paramQueryFilter) {
38 - Object value = super.queryWithCache(paramQueryFilter,PagePersonalFactor.class);  
39 - return value==null?null:(PagePersonalFactor)value; 39 + Object value = super.queryWithCache(paramQueryFilter, PagePersonalFactor.class);
  40 + return value == null ? null : (PagePersonalFactor) value;
40 } 41 }
41 42
42 @Override 43 @Override
43 protected RedisKeyBuilder genRedisKeyBuilder(ParamQueryFilter paramQueryFilter) { 44 protected RedisKeyBuilder genRedisKeyBuilder(ParamQueryFilter paramQueryFilter) {
44 - return RedisKeyBuilder.newInstance().appendFixed("YOHOSEARCH:").appendFixed("PAGE_FACTOR:").appendVar(paramQueryFilter.getParamMd5Key()); 45 + return RedisKeyBuilder.newInstance().appendFixed("YOHOSEARCH:").appendFixed("PAGE_FACTORS:").appendVar(paramQueryFilter.getParamMd5Key());
45 } 46 }
46 47
47 @Override 48 @Override
@@ -74,17 +75,32 @@ public class PagePersionalFactorComponent extends AbstractPageComponent<PagePers @@ -74,17 +75,32 @@ public class PagePersionalFactorComponent extends AbstractPageComponent<PagePers
74 Map<String, Aggregation> aggregationMap = searchResult.getAggMaps(); 75 Map<String, Aggregation> aggregationMap = searchResult.getAggMaps();
75 List<SortBrand> sortBrands = this.getBrandSortsFromAggregationMap(aggregationMap); 76 List<SortBrand> sortBrands = this.getBrandSortsFromAggregationMap(aggregationMap);
76 List<Integer> misortIds = this.getMisortIds(sortBrands); 77 List<Integer> misortIds = this.getMisortIds(sortBrands);
77 - return new PagePersonalFactor(sortBrands,misortIds); 78 + List<Integer> brandIds = this.getBrandIds(sortBrands);
  79 + return new PagePersonalFactor(misortIds, brandIds, sortBrands);
78 } 80 }
79 81
80 - private List<Integer> getMisortIds(List<SortBrand> sortBrands){  
81 - if(sortBrands==null||sortBrands.isEmpty()){ 82 + private List<Integer> getMisortIds(List<SortBrand> sortBrands) {
  83 + if (sortBrands == null || sortBrands.isEmpty()) {
82 return new ArrayList<>(); 84 return new ArrayList<>();
83 } 85 }
84 List<Integer> results = new ArrayList<>(); 86 List<Integer> results = new ArrayList<>();
85 for (SortBrand sortBrand : sortBrands) { 87 for (SortBrand sortBrand : sortBrands) {
86 Integer misort = sortBrand.getMisort(); 88 Integer misort = sortBrand.getMisort();
87 - if(!results.contains(misort)){ 89 + if (!results.contains(misort)) {
  90 + results.add(misort);
  91 + }
  92 + }
  93 + return results;
  94 + }
  95 +
  96 + private List<Integer> getBrandIds(List<SortBrand> sortBrands) {
  97 + if (sortBrands == null || sortBrands.isEmpty()) {
  98 + return new ArrayList<>();
  99 + }
  100 + List<Integer> results = new ArrayList<>();
  101 + for (SortBrand sortBrand : sortBrands) {
  102 + Integer misort = sortBrand.getMisort();
  103 + if (!results.contains(misort)) {
88 results.add(misort); 104 results.add(misort);
89 } 105 }
90 } 106 }
@@ -102,14 +118,14 @@ public class PagePersionalFactorComponent extends AbstractPageComponent<PagePers @@ -102,14 +118,14 @@ public class PagePersionalFactorComponent extends AbstractPageComponent<PagePers
102 return middleSortAggBuilder; 118 return middleSortAggBuilder;
103 } 119 }
104 120
105 - private List<SortBrand> getBrandSortsFromAggregationMap(Map<String, Aggregation> aggregationMap) {  
106 - Map<Integer,List<Integer>> brand2MiSortIdsMap = this.getValueFromAggregationMap(aggregationMap,"sortBrandBrandIdAgg","sortBrandMiddleSortAgg"); 121 + private List<SortBrand> getBrandSortsFromAggregationMap(Map<String, Aggregation> aggregationMap) {
  122 + Map<Integer, List<Integer>> brand2MiSortIdsMap = this.getValueFromAggregationMap(aggregationMap, "sortBrandBrandIdAgg", "sortBrandMiddleSortAgg");
107 List<SortBrand> pageBrandSorts = new ArrayList<>(); 123 List<SortBrand> pageBrandSorts = new ArrayList<>();
108 - for (Map.Entry<Integer,List<Integer>> entry: brand2MiSortIdsMap.entrySet()) { 124 + for (Map.Entry<Integer, List<Integer>> entry : brand2MiSortIdsMap.entrySet()) {
109 Integer brandId = entry.getKey(); 125 Integer brandId = entry.getKey();
110 List<Integer> misorts = entry.getValue(); 126 List<Integer> misorts = entry.getValue();
111 - for (Integer misort: misorts) {  
112 - pageBrandSorts.add(new SortBrand(misort,brandId)); 127 + for (Integer misort : misorts) {
  128 + pageBrandSorts.add(new SortBrand(misort, brandId));
113 } 129 }
114 } 130 }
115 return pageBrandSorts; 131 return pageBrandSorts;
@@ -117,14 +133,15 @@ public class PagePersionalFactorComponent extends AbstractPageComponent<PagePers @@ -117,14 +133,15 @@ public class PagePersionalFactorComponent extends AbstractPageComponent<PagePers
117 133
118 /** 134 /**
119 * 从聚合结果中获取参数,仅支持二层聚合 135 * 从聚合结果中获取参数,仅支持二层聚合
  136 + *
120 * @param aggregationMap 137 * @param aggregationMap
121 * @param firstAggName 138 * @param firstAggName
122 * @param secondAggName 139 * @param secondAggName
123 * @return 140 * @return
124 */ 141 */
125 - private Map<Integer,List<Integer>> getValueFromAggregationMap(Map<String, Aggregation> aggregationMap,String firstAggName,String secondAggName){  
126 - Map<Integer,List<Integer>> aggResultMap = new HashMap<>();  
127 - if(!aggregationMap.containsKey(firstAggName)){ 142 + private Map<Integer, List<Integer>> getValueFromAggregationMap(Map<String, Aggregation> aggregationMap, String firstAggName, String secondAggName) {
  143 + Map<Integer, List<Integer>> aggResultMap = new HashMap<>();
  144 + if (!aggregationMap.containsKey(firstAggName)) {
128 return aggResultMap; 145 return aggResultMap;
129 } 146 }
130 MultiBucketsAggregation firstAggregation = (MultiBucketsAggregation) aggregationMap.get(firstAggName); 147 MultiBucketsAggregation firstAggregation = (MultiBucketsAggregation) aggregationMap.get(firstAggName);
@@ -132,19 +149,19 @@ public class PagePersionalFactorComponent extends AbstractPageComponent<PagePers @@ -132,19 +149,19 @@ public class PagePersionalFactorComponent extends AbstractPageComponent<PagePers
132 while (firstAggregationIterator.hasNext()) { 149 while (firstAggregationIterator.hasNext()) {
133 MultiBucketsAggregation.Bucket firstAggregationBucket = firstAggregationIterator.next(); 150 MultiBucketsAggregation.Bucket firstAggregationBucket = firstAggregationIterator.next();
134 Integer firstAggregationBucketKey = Integer.valueOf(firstAggregationBucket.getKeyAsString()); 151 Integer firstAggregationBucketKey = Integer.valueOf(firstAggregationBucket.getKeyAsString());
135 - Map<String, Aggregation> secondAggregationMap = firstAggregationBucket.getAggregations().asMap();  
136 - if(secondAggregationMap==null || !secondAggregationMap.containsKey(secondAggName)){ 152 + Map<String, Aggregation> secondAggregationMap = firstAggregationBucket.getAggregations().asMap();
  153 + if (secondAggregationMap == null || !secondAggregationMap.containsKey(secondAggName)) {
137 continue; 154 continue;
138 } 155 }
139 - List<Integer> secondAggregationBucketKeys = this.getAggValuesFromMultiBucketsAggregation((MultiBucketsAggregation)secondAggregationMap.get(secondAggName));  
140 - aggResultMap.put(firstAggregationBucketKey,secondAggregationBucketKeys); 156 + List<Integer> secondAggregationBucketKeys = this.getAggValuesFromMultiBucketsAggregation((MultiBucketsAggregation) secondAggregationMap.get(secondAggName));
  157 + aggResultMap.put(firstAggregationBucketKey, secondAggregationBucketKeys);
141 } 158 }
142 return aggResultMap; 159 return aggResultMap;
143 } 160 }
144 161
145 - private List<Integer> getAggValuesFromMultiBucketsAggregation(MultiBucketsAggregation aggregation){ 162 + private List<Integer> getAggValuesFromMultiBucketsAggregation(MultiBucketsAggregation aggregation) {
146 List<Integer> results = new ArrayList<>(); 163 List<Integer> results = new ArrayList<>();
147 - if(aggregation==null){ 164 + if (aggregation == null) {
148 return results; 165 return results;
149 } 166 }
150 Iterator<? extends MultiBucketsAggregation.Bucket> bucketsIterator = aggregation.getBuckets().iterator(); 167 Iterator<? extends MultiBucketsAggregation.Bucket> bucketsIterator = aggregation.getBuckets().iterator();
@@ -53,29 +53,26 @@ public class QueryUserPersionalFactorBean { @@ -53,29 +53,26 @@ public class QueryUserPersionalFactorBean {
53 long begin = System.currentTimeMillis(); 53 long begin = System.currentTimeMillis();
54 PagePersonalFactor pageFactor = pageComponent.queryPagePersionalFactor(userRecallRequest.getParamQueryFilter()); 54 PagePersonalFactor pageFactor = pageComponent.queryPagePersionalFactor(userRecallRequest.getParamQueryFilter());
55 long cost = System.currentTimeMillis() - begin; 55 long cost = System.currentTimeMillis() - begin;
56 - RECALL_NEW_LOGGER.info("QueryUserPersionalFactorBean[1]:queryPageFactor. uid is[{}],udid is[{}], cost is[{}],size is[{}] ", uid, udid, cost, pageFactor == null ? "null" : pageFactor.sortBrandListSize()); 56 + RECALL_NEW_LOGGER.info("QueryUserPersionalFactorBean[1]:queryPageFactor. uid is[{}],udid is[{}], cost is[{}]] ms", uid, udid, cost);
57 57
58 //2、获取用户的个性化因子 58 //2、获取用户的个性化因子
59 begin = System.currentTimeMillis(); 59 begin = System.currentTimeMillis();
60 UserPersonalFactorRspNew userFactor = userComponent.queryUserPersionalFactor(userRecallRequest.getUid(), userRecallRequest.getUdid(), pageFactor.getMisortIds()); 60 UserPersonalFactorRspNew userFactor = userComponent.queryUserPersionalFactor(userRecallRequest.getUid(), userRecallRequest.getUdid(), pageFactor.getMisortIds());
61 cost = System.currentTimeMillis() - begin; 61 cost = System.currentTimeMillis() - begin;
62 - int forecastSortBrandSize = userFactor.getSortBrandList().size();  
63 - int realTimeSortBrandSize = userFactor.getRealTimeSortBrandList().size();  
64 - int recommendSknSize = userFactor.getRecommendSknList().size();  
65 - if (!openDetailLog) {  
66 - RECALL_NEW_LOGGER.info("QueryUserPersionalFactorBean[2]:queryUserFactor. uid is[{}],udid is[{}], cost is[{}], forecastSortBrandSize is[{}],realTimeSortBrandSize is[{}], recommendSknSize is[{}] ", uid, udid, cost, forecastSortBrandSize, realTimeSortBrandSize, recommendSknSize);  
67 - } else {  
68 - RECALL_NEW_LOGGER.info("QueryUserPersionalFactorBean[2]:queryUserFactor. uid is[{}],udid is[{}], cost is[{}], forecastSortBrandSize is[{}],realTimeSortBrandSize is[{}], recommendSknSize is[{}],misortIds is[{}],userFactor is[{}] ", uid, udid, cost, forecastSortBrandSize, realTimeSortBrandSize, recommendSknSize, pageFactor.getMisortIds(), JSON.toJSONString(userFactor));  
69 - } 62 +
  63 + StringBuilder sizeLogInfo = new StringBuilder();
  64 + sizeLogInfo.append("SKN_SIZE is ").append(userFactor.getRecommendSknList().size()).append(";");
  65 + sizeLogInfo.append("RT_SB_SIZE is ").append(userFactor.getRealTimeSortBrandList().size()).append(";");
  66 + sizeLogInfo.append("PRED_SB_SIZE is ").append(userFactor.getSortBrandList().size()).append(";");
  67 + sizeLogInfo.append("VECTOR_RNN_SIZE is ").append(userFactor.getBrandVector().size()).append("_").append(userFactor.getSortBrandVector().size()).append(";");
  68 + sizeLogInfo.append("VECTOR_W2C_SIZE is ").append(userFactor.getBrandVectorW2v().size()).append("_").append(userFactor.getSortBrandVectorW2v().size()).append(";");
  69 + RECALL_NEW_LOGGER.info("QueryUserPersionalFactorBean[2]:queryUserFactor. uid is[{}],udid is[{}], cost is[{}], size info is [{}] ", uid, udid, cost, sizeLogInfo.toString());
  70 +
70 //3、构造结果 71 //3、构造结果
71 begin = System.currentTimeMillis(); 72 begin = System.currentTimeMillis();
72 UserPersonalFactor userPersonalFactor = this.buildUserPersonalFactor(pageFactor, userFactor); 73 UserPersonalFactor userPersonalFactor = this.buildUserPersonalFactor(pageFactor, userFactor);
73 cost = System.currentTimeMillis() - begin; 74 cost = System.currentTimeMillis() - begin;
74 - if (!openDetailLog) {  
75 - RECALL_NEW_LOGGER.info("QueryUserPersionalFactorBean[3]:buildUserPersonalFactor.cost is[{}ms], uid is[{}],udid is[{}], predictSortBrandSize size is[{}], realTimeSortBrand size is[{}], vectorSortBrand size is[{}], sortPriceAreas size is [{}] ", cost, uid, udid, userPersonalFactor.getPredictSortBrandListSize(), userPersonalFactor.getRealTimeSortBrandListSize(), userPersonalFactor.getVectorSortBrandListSize(), userPersonalFactor.getSortPriceAreasListSize());  
76 - } else {  
77 - RECALL_NEW_LOGGER.info("QueryUserPersionalFactorBean[3]:buildUserPersonalFactor.cost is[{}ms], uid is[{}],udid is[{}], predictSortBrandSize size is[{}], realTimeSortBrand size is[{}], vectorSortBrand size is[{}], sortPriceAreas size is [{}], results is [{}] ", cost, uid, udid, userPersonalFactor.getPredictSortBrandListSize(), userPersonalFactor.getRealTimeSortBrandListSize(), userPersonalFactor.getVectorSortBrandListSize(), userPersonalFactor.getSortPriceAreasListSize(), JSON.toJSONString(userPersonalFactor));  
78 - } 75 + RECALL_NEW_LOGGER.info("QueryUserPersionalFactorBean[3]:buildUserPersonalFactor, uid is[{}],udid is[{}], cost is[{}ms],", uid, udid, cost);
79 return userPersonalFactor; 76 return userPersonalFactor;
80 } catch (Exception e) { 77 } catch (Exception e) {
81 logger.error(e.getMessage(), e); 78 logger.error(e.getMessage(), e);
@@ -84,39 +81,43 @@ public class QueryUserPersionalFactorBean { @@ -84,39 +81,43 @@ public class QueryUserPersionalFactorBean {
84 } 81 }
85 82
86 private UserPersonalFactor buildUserPersonalFactor(PagePersonalFactor pageFactor, UserPersonalFactorRspNew userFactor) { 83 private UserPersonalFactor buildUserPersonalFactor(PagePersonalFactor pageFactor, UserPersonalFactorRspNew userFactor) {
87 - //1、获取页面中存在的所有的key 84 + //1、构造品类价格带
  85 + List<SortPriceAreas> sortPriceAreasList = this.getSortPriceAreasListWithSort(userFactor, pageFactor);
  86 + //2、构造推荐的skn列表
  87 + List<Integer> recommendSknList = userFactor.getRecommendSknList();
  88 +
  89 + //3、获取页面中存在的所有的key
88 Set<String> pageSortBrandKeys = new HashSet<>(); 90 Set<String> pageSortBrandKeys = new HashSet<>();
89 Set<String> filterSortBrandKeys = new HashSet<>(); 91 Set<String> filterSortBrandKeys = new HashSet<>();
90 for (SortBrand pageSortBrand : pageFactor.getSortBrandList()) { 92 for (SortBrand pageSortBrand : pageFactor.getSortBrandList()) {
91 pageSortBrandKeys.add(pageSortBrand.key()); 93 pageSortBrandKeys.add(pageSortBrand.key());
92 } 94 }
93 - //2、构造实时【品类+品牌】 95 + //4、构造实时【品类+品牌】
94 int maxRealTimeSortBrandCount = RecallCommonConstants.maxRealTimeSortBrandCount; 96 int maxRealTimeSortBrandCount = RecallCommonConstants.maxRealTimeSortBrandCount;
95 List<SortBrand> realTimeSortBrandList = this.getSortBrandListWithSort(pageSortBrandKeys, filterSortBrandKeys, userFactor.getRealTimeSortBrandList(), maxRealTimeSortBrandCount); 97 List<SortBrand> realTimeSortBrandList = this.getSortBrandListWithSort(pageSortBrandKeys, filterSortBrandKeys, userFactor.getRealTimeSortBrandList(), maxRealTimeSortBrandCount);
96 for (SortBrand existSortBrand : realTimeSortBrandList) { 98 for (SortBrand existSortBrand : realTimeSortBrandList) {
97 filterSortBrandKeys.add(existSortBrand.key()); 99 filterSortBrandKeys.add(existSortBrand.key());
98 } 100 }
99 - //3、构造基于向量的【品牌+品牌】,去除实时的品类和品牌  
100 - int maxVectorSortBrandCount = RecallCommonConstants.maxVectorSortBrandCount;  
101 - List<SortBrand> vectorSortBrandList = sortBrandVectorComponent.queryRnnVectorSortBrandList(pageFactor.getSortBrandList(), filterSortBrandKeys, userFactor.getSortBrandVector(), maxVectorSortBrandCount);  
102 - for (SortBrand existSortBrand : vectorSortBrandList) {  
103 - filterSortBrandKeys.add(existSortBrand.key());  
104 - }  
105 - //4、构造预测的【品牌+品牌】,去除实时的品类和品牌 101 + //5、构造预测的【品牌+品牌】,去除实时的品类和品牌
106 int maxPredictSortBrandCount = RecallCommonConstants.maxPredictSortBrandCount; 102 int maxPredictSortBrandCount = RecallCommonConstants.maxPredictSortBrandCount;
107 List<SortBrand> forecastSortBrandList = this.getSortBrandListWithSort(pageSortBrandKeys, filterSortBrandKeys, userFactor.getSortBrandList(), maxPredictSortBrandCount); 103 List<SortBrand> forecastSortBrandList = this.getSortBrandListWithSort(pageSortBrandKeys, filterSortBrandKeys, userFactor.getSortBrandList(), maxPredictSortBrandCount);
108 for (SortBrand existSortBrand : forecastSortBrandList) { 104 for (SortBrand existSortBrand : forecastSortBrandList) {
109 filterSortBrandKeys.add(existSortBrand.key()); 105 filterSortBrandKeys.add(existSortBrand.key());
110 } 106 }
111 -  
112 - //5、构造品类价格带  
113 - List<SortPriceAreas> sortPriceAreasList = this.getSortPriceAreasListWithSort(userFactor, pageFactor);  
114 -  
115 - //6、构造推荐的skn列表  
116 - List<Integer> recommendSknList = userFactor.getRecommendSknList();  
117 -  
118 - //7、返回最终结果  
119 - return new UserPersonalFactor(realTimeSortBrandList, forecastSortBrandList, vectorSortBrandList, sortPriceAreasList, recommendSknList); 107 + //6、构造基于RNN向量的【品牌+品牌】,去除实时的品类和品牌
  108 + int maxVectorRNNSortBrandCount = RecallCommonConstants.maxVectorRNNSortBrandCount;
  109 + List<SortBrand> vectorRnnSortBrandList = sortBrandVectorComponent.queryRnnVectorSortBrandList(pageFactor, filterSortBrandKeys, userFactor.getBrandVector(), userFactor.getSortBrandVector(), maxVectorRNNSortBrandCount);
  110 + for (SortBrand existSortBrand : vectorRnnSortBrandList) {
  111 + filterSortBrandKeys.add(existSortBrand.key());
  112 + }
  113 + //7、构造基于W2V向量的【品牌+品牌】,去除实时的品类和品牌
  114 + int maxVectorW2SortBrandCount = RecallCommonConstants.maxVectorW2SortBrandCount;
  115 + List<SortBrand> vectorW2vSortBrandList = sortBrandVectorComponent.queryW2VectorSortBrandList(pageFactor, filterSortBrandKeys, userFactor.getBrandVector(), userFactor.getSortBrandVectorW2v(), maxVectorW2SortBrandCount);
  116 + for (SortBrand existSortBrand : vectorW2vSortBrandList) {
  117 + filterSortBrandKeys.add(existSortBrand.key());
  118 + }
  119 + //8、返回最终结果
  120 + return new UserPersonalFactor(recommendSknList, sortPriceAreasList, realTimeSortBrandList, forecastSortBrandList, vectorRnnSortBrandList, vectorW2vSortBrandList);
120 } 121 }
121 122
122 private List<SortBrand> getSortBrandListWithSort(Set<String> pageSortBrandKeys, Set<String> filterSortBrandKeys, List<SortBrand> userSortBrands, int maxCount) { 123 private List<SortBrand> getSortBrandListWithSort(Set<String> pageSortBrandKeys, Set<String> filterSortBrandKeys, List<SortBrand> userSortBrands, int maxCount) {
@@ -29,27 +29,45 @@ public class UserPersionalFactorComponent { @@ -29,27 +29,45 @@ public class UserPersionalFactorComponent {
29 * @param udid 29 * @param udid
30 * @return 30 * @return
31 */ 31 */
32 - public UserPersonalFactorRspNew queryUserPersionalFactor(int uid, String udid,List<Integer> misortIds) { 32 + public UserPersonalFactorRspNew queryUserPersionalFactor(int uid, String udid, List<Integer> misortIds) {
33 try { 33 try {
34 - UserPersonalFactorReq userPersionalFactorReq = new UserPersonalFactorReq(uid, udid,misortIds); 34 + UserPersonalFactorReq userPersionalFactorReq = new UserPersonalFactorReq(uid, udid, misortIds);
35 JSONObject result = serviceCaller.call(SERVICE_NAME, userPersionalFactorReq, JSONObject.class, timeOut); 35 JSONObject result = serviceCaller.call(SERVICE_NAME, userPersionalFactorReq, JSONObject.class, timeOut);
36 JSONObject userPersonalFactorRspJSon = result.getJSONObject("data"); 36 JSONObject userPersonalFactorRspJSon = result.getJSONObject("data");
37 UserPersonalFactorRspNew rsp = JSON.toJavaObject(userPersonalFactorRspJSon, UserPersonalFactorRspNew.class); 37 UserPersonalFactorRspNew rsp = JSON.toJavaObject(userPersonalFactorRspJSon, UserPersonalFactorRspNew.class);
38 if (rsp == null) { 38 if (rsp == null) {
39 rsp = new UserPersonalFactorRspNew(); 39 rsp = new UserPersonalFactorRspNew();
40 } 40 }
41 - if(rsp.getSortBrandList()==null){  
42 - rsp.setSortBrandList(new ArrayList<>()); 41 + //skn
  42 + if (rsp.getRecommendSknList() == null) {
  43 + rsp.setRecommendSknList(new ArrayList<>());
  44 + }
  45 + //价格带
  46 + if (rsp.getSortPriceAreasList() == null) {
  47 + rsp.setSortPriceAreasList(new ArrayList<>());
43 } 48 }
44 - if(rsp.getRealTimeSortBrandList()==null){ 49 + //实时的品类品牌
  50 + if (rsp.getRealTimeSortBrandList() == null) {
45 rsp.setRealTimeSortBrandList(new ArrayList<>()); 51 rsp.setRealTimeSortBrandList(new ArrayList<>());
46 } 52 }
47 - if(rsp.getSortPriceAreasList()==null){  
48 - rsp.setSortPriceAreasList(new ArrayList<>()); 53 + //预测的品类品牌
  54 + if (rsp.getSortBrandList() == null) {
  55 + rsp.setSortBrandList(new ArrayList<>());
  56 + }
  57 + //RNN的向量
  58 + if (rsp.getBrandVector() == null) {
  59 + rsp.setBrandVector(new ArrayList<>());
49 } 60 }
50 - if(rsp.getSortBrandVector()==null){ 61 + if (rsp.getSortBrandVector() == null) {
51 rsp.setSortBrandVector(new ArrayList<>()); 62 rsp.setSortBrandVector(new ArrayList<>());
52 } 63 }
  64 + //w2v的的向量
  65 + if (rsp.getSortBrandVectorW2v() == null) {
  66 + rsp.setSortBrandVectorW2v(new ArrayList<>());
  67 + }
  68 + if (rsp.getBrandVectorW2v() == null) {
  69 + rsp.setBrandVectorW2v(new ArrayList<>());
  70 + }
53 return rsp; 71 return rsp;
54 } catch (Exception e) { 72 } catch (Exception e) {
55 RECALL_NEW_LOGGER.error(e.getMessage(), e); 73 RECALL_NEW_LOGGER.error(e.getMessage(), e);
@@ -3,5 +3,6 @@ package com.yoho.search.recall.scene.beans.strategy; @@ -3,5 +3,6 @@ package com.yoho.search.recall.scene.beans.strategy;
3 public enum SortBrandType { 3 public enum SortBrandType {
4 REC_SORT_BRAND, 4 REC_SORT_BRAND,
5 PRED_SORT_BRAND, 5 PRED_SORT_BRAND,
6 - VEC_SORT_BRAND 6 + VEC_RNN_SORT_BRAND,
  7 + VEC_W2V_SORT_BRAND
7 } 8 }
@@ -7,23 +7,29 @@ public enum StrategyEnum { @@ -7,23 +7,29 @@ public enum StrategyEnum {
7 7
8 REC_SKN(99),//实时推荐的skn 8 REC_SKN(99),//实时推荐的skn
9 9
10 - REC_S_B_HEAT_VALUE(40),//实时的品牌+品类的人气值  
11 - REC_S_B_CTR_VALUE(41),//实时的品牌+品类的转化率  
12 - REC_S_B_REDUCE_PRICE(42),//实时的品牌+品类的最新降价  
13 - REC_S_B_PROMOTION(43),//实时的品牌+品类的新开促销  
14 - REC_S_B_NEW(44),//实时的品牌+品类的新品  
15 -  
16 - VEC_S_B_HEAT_VALUE(30),//向量预测的品牌+品类的人气值  
17 - VEC_S_B_CTR_VALUE(31),//实时的品牌+品类的转化率  
18 - VEC_S_B_REDUCE_PRICE(32),//向量预测的品牌+品类的最新降价  
19 - VEC_S_B_PROMOTION(33),//向量预测的品牌+品类的新开促销  
20 - VEC_S_B_NEW(34),//向量预测的品牌+品类的新品  
21 -  
22 - PRED_S_B_HEAT_VALUE(20),//预测的品牌+品类的人气值  
23 - PRED_S_B_CTR_VALUE(21),//预测的品牌+品类的转化率  
24 - PRED_S_B_REDUCE_PRICE(22),//预测的品牌+品类的最新降价  
25 - PRED_S_B_PROMOTION(23),//预测的品牌+品类的新开促销  
26 - PRED_S_B_NEW(24),//预测的品牌+品类的新品 10 + REC_S_B_HEAT_VALUE(80),//实时的品牌+品类的人气值
  11 + REC_S_B_CTR_VALUE(81),//实时的品牌+品类的转化率
  12 + REC_S_B_REDUCE_PRICE(82),//实时的品牌+品类的最新降价
  13 + REC_S_B_PROMOTION(83),//实时的品牌+品类的新开促销
  14 + REC_S_B_NEW(84),//实时的品牌+品类的新品
  15 +
  16 + PRED_S_B_HEAT_VALUE(70),//预测的品牌+品类的人气值
  17 + PRED_S_B_CTR_VALUE(71),//预测的品牌+品类的转化率
  18 + PRED_S_B_REDUCE_PRICE(72),//预测的品牌+品类的最新降价
  19 + PRED_S_B_PROMOTION(73),//预测的品牌+品类的新开促销
  20 + PRED_S_B_NEW(74),//预测的品牌+品类的新品
  21 +
  22 + VEC_RNN_S_B_HEAT_VALUE(60),//向量预测的品牌+品类的人气值
  23 + VEC_RNN_S_B_CTR_VALUE(61),//实时的品牌+品类的转化率
  24 + VEC_RNN_S_B_REDUCE_PRICE(62),//向量预测的品牌+品类的最新降价
  25 + VEC_RNN_S_B_PROMOTION(63),//向量预测的品牌+品类的新开促销
  26 + VEC_RNN_S_B_NEW(64),//向量预测的品牌+品类的新品
  27 +
  28 + VEC_W2V_S_B_HEAT_VALUE(50),//向量预测的品牌+品类的人气值
  29 + VEC_W2V_S_B_CTR_VALUE(51),//实时的品牌+品类的转化率
  30 + VEC_W2V_S_B_REDUCE_PRICE(52),//向量预测的品牌+品类的最新降价
  31 + VEC_W2V_S_B_PROMOTION(53),//向量预测的品牌+品类的新开促销
  32 + VEC_W2V_S_B_NEW(54),//向量预测的品牌+品类的新品
27 33
28 ADD_FLOW(12),//流量补偿 34 ADD_FLOW(12),//流量补偿
29 NEW_SHOP(11),//新开店铺 35 NEW_SHOP(11),//新开店铺
@@ -16,7 +16,7 @@ public abstract class SortBrandAbstractStrategy implements IStrategy { @@ -16,7 +16,7 @@ public abstract class SortBrandAbstractStrategy implements IStrategy {
16 public SortBrandAbstractStrategy(SortBrand sortBrand, int size, SortBrandType sortBrandType) { 16 public SortBrandAbstractStrategy(SortBrand sortBrand, int size, SortBrandType sortBrandType) {
17 this.sortBrand = sortBrand; 17 this.sortBrand = sortBrand;
18 this.size = size; 18 this.size = size;
19 - this.sortBrandType=sortBrandType; 19 + this.sortBrandType = sortBrandType;
20 } 20 }
21 21
22 @Override 22 @Override
@@ -32,71 +32,81 @@ public abstract class SortBrandAbstractStrategy implements IStrategy { @@ -32,71 +32,81 @@ public abstract class SortBrandAbstractStrategy implements IStrategy {
32 @Override 32 @Override
33 public String strategyCacheKey() { 33 public String strategyCacheKey() {
34 StringBuilder sb = defaultStrategyKey(); 34 StringBuilder sb = defaultStrategyKey();
35 - sb.append(this.sortBrand==null?"": JSON.toJSONString(this.sortBrand)); 35 + sb.append(this.sortBrand == null ? "" : JSON.toJSONString(this.sortBrand));
36 return sb.toString(); 36 return sb.toString();
37 } 37 }
38 38
39 - public StrategyEnum heatValueStrategyEnum(SortBrandType sortBrandType){  
40 - switch (sortBrandType){ 39 + public StrategyEnum heatValueStrategyEnum(SortBrandType sortBrandType) {
  40 + switch (sortBrandType) {
41 case REC_SORT_BRAND: 41 case REC_SORT_BRAND:
42 return StrategyEnum.REC_S_B_HEAT_VALUE; 42 return StrategyEnum.REC_S_B_HEAT_VALUE;
43 case PRED_SORT_BRAND: 43 case PRED_SORT_BRAND:
44 return StrategyEnum.PRED_S_B_HEAT_VALUE; 44 return StrategyEnum.PRED_S_B_HEAT_VALUE;
45 - case VEC_SORT_BRAND:  
46 - return StrategyEnum.VEC_S_B_HEAT_VALUE; 45 + case VEC_RNN_SORT_BRAND:
  46 + return StrategyEnum.VEC_RNN_S_B_HEAT_VALUE;
  47 + case VEC_W2V_SORT_BRAND:
  48 + return StrategyEnum.VEC_W2V_S_B_HEAT_VALUE;
47 default: 49 default:
48 return null; 50 return null;
49 } 51 }
50 } 52 }
51 53
52 - public StrategyEnum ctrValueStrategyEnum(SortBrandType sortBrandType){  
53 - switch (sortBrandType){ 54 + public StrategyEnum ctrValueStrategyEnum(SortBrandType sortBrandType) {
  55 + switch (sortBrandType) {
54 case REC_SORT_BRAND: 56 case REC_SORT_BRAND:
55 return StrategyEnum.REC_S_B_CTR_VALUE; 57 return StrategyEnum.REC_S_B_CTR_VALUE;
56 case PRED_SORT_BRAND: 58 case PRED_SORT_BRAND:
57 return StrategyEnum.PRED_S_B_CTR_VALUE; 59 return StrategyEnum.PRED_S_B_CTR_VALUE;
58 - case VEC_SORT_BRAND:  
59 - return StrategyEnum.VEC_S_B_CTR_VALUE; 60 + case VEC_RNN_SORT_BRAND:
  61 + return StrategyEnum.VEC_RNN_S_B_CTR_VALUE;
  62 + case VEC_W2V_SORT_BRAND:
  63 + return StrategyEnum.VEC_W2V_S_B_CTR_VALUE;
60 default: 64 default:
61 return null; 65 return null;
62 } 66 }
63 } 67 }
64 68
65 - public StrategyEnum newStrategyEnum(SortBrandType sortBrandType){  
66 - switch (sortBrandType){ 69 + public StrategyEnum newStrategyEnum(SortBrandType sortBrandType) {
  70 + switch (sortBrandType) {
67 case REC_SORT_BRAND: 71 case REC_SORT_BRAND:
68 return StrategyEnum.REC_S_B_NEW; 72 return StrategyEnum.REC_S_B_NEW;
69 case PRED_SORT_BRAND: 73 case PRED_SORT_BRAND:
70 return StrategyEnum.PRED_S_B_NEW; 74 return StrategyEnum.PRED_S_B_NEW;
71 - case VEC_SORT_BRAND:  
72 - return StrategyEnum.VEC_S_B_NEW; 75 + case VEC_RNN_SORT_BRAND:
  76 + return StrategyEnum.VEC_RNN_S_B_NEW;
  77 + case VEC_W2V_SORT_BRAND:
  78 + return StrategyEnum.VEC_W2V_S_B_NEW;
73 default: 79 default:
74 return null; 80 return null;
75 } 81 }
76 } 82 }
77 83
78 - public StrategyEnum promotionStrategyEnum(SortBrandType sortBrandType){  
79 - switch (sortBrandType){ 84 + public StrategyEnum promotionStrategyEnum(SortBrandType sortBrandType) {
  85 + switch (sortBrandType) {
80 case REC_SORT_BRAND: 86 case REC_SORT_BRAND:
81 return StrategyEnum.REC_S_B_PROMOTION; 87 return StrategyEnum.REC_S_B_PROMOTION;
82 case PRED_SORT_BRAND: 88 case PRED_SORT_BRAND:
83 return StrategyEnum.PRED_S_B_PROMOTION; 89 return StrategyEnum.PRED_S_B_PROMOTION;
84 - case VEC_SORT_BRAND:  
85 - return StrategyEnum.VEC_S_B_PROMOTION; 90 + case VEC_RNN_SORT_BRAND:
  91 + return StrategyEnum.VEC_RNN_S_B_PROMOTION;
  92 + case VEC_W2V_SORT_BRAND:
  93 + return StrategyEnum.VEC_W2V_S_B_PROMOTION;
86 default: 94 default:
87 return null; 95 return null;
88 } 96 }
89 97
90 } 98 }
91 99
92 - public StrategyEnum reducePriceStrategyEnum(SortBrandType sortBrandType){  
93 - switch (sortBrandType){ 100 + public StrategyEnum reducePriceStrategyEnum(SortBrandType sortBrandType) {
  101 + switch (sortBrandType) {
94 case REC_SORT_BRAND: 102 case REC_SORT_BRAND:
95 return StrategyEnum.REC_S_B_REDUCE_PRICE; 103 return StrategyEnum.REC_S_B_REDUCE_PRICE;
96 case PRED_SORT_BRAND: 104 case PRED_SORT_BRAND:
97 return StrategyEnum.PRED_S_B_REDUCE_PRICE; 105 return StrategyEnum.PRED_S_B_REDUCE_PRICE;
98 - case VEC_SORT_BRAND:  
99 - return StrategyEnum.VEC_S_B_REDUCE_PRICE; 106 + case VEC_RNN_SORT_BRAND:
  107 + return StrategyEnum.VEC_RNN_S_B_REDUCE_PRICE;
  108 + case VEC_W2V_SORT_BRAND:
  109 + return StrategyEnum.VEC_W2V_S_B_REDUCE_PRICE;
100 default: 110 default:
101 return null; 111 return null;
102 } 112 }
@@ -4,6 +4,7 @@ import com.yoho.search.base.helper.RnnVectorCalculator; @@ -4,6 +4,7 @@ import com.yoho.search.base.helper.RnnVectorCalculator;
4 import com.yoho.search.base.helper.Word2VectorCalculator; 4 import com.yoho.search.base.helper.Word2VectorCalculator;
5 import com.yoho.search.base.utils.CollectionUtils; 5 import com.yoho.search.base.utils.CollectionUtils;
6 import com.yoho.search.core.personalized.models.SortBrand; 6 import com.yoho.search.core.personalized.models.SortBrand;
  7 +import com.yoho.search.recall.scene.models.personal.PagePersonalFactor;
7 import com.yoho.search.recall.scene.models.personal.SortBrandVectorScore; 8 import com.yoho.search.recall.scene.models.personal.SortBrandVectorScore;
8 import org.springframework.beans.factory.annotation.Autowired; 9 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.stereotype.Component; 10 import org.springframework.stereotype.Component;
@@ -19,20 +20,24 @@ public class SortBrandVectorComponent { @@ -19,20 +20,24 @@ public class SortBrandVectorComponent {
19 @Autowired 20 @Autowired
20 private SortBrandVectorCacheBean sortBrandVectorCacheBean; 21 private SortBrandVectorCacheBean sortBrandVectorCacheBean;
21 22
22 - public List<SortBrand> queryRnnVectorSortBrandList(List<SortBrand> pageSortBrands, Set<String> filterKeys, List<Double> userVectorList, int filterCount) {  
23 - if (userVectorList == null || userVectorList.isEmpty()) { 23 + public List<SortBrand> queryRnnVectorSortBrandList(PagePersonalFactor pageFactor, Set<String> filterSortBrandKeys, List<Double> userBrandVector, List<Double> userSortBrandVector, int filterCount) {
  24 + if (userSortBrandVector == null || userSortBrandVector.isEmpty()) {
  25 + return new ArrayList<>();
  26 + }
  27 + List<SortBrand> pageSortBrands = pageFactor.getSortBrandList();
  28 + if (pageSortBrands == null || pageSortBrands.isEmpty()) {
24 return new ArrayList<>(); 29 return new ArrayList<>();
25 } 30 }
26 List<SortBrandVectorScore> sortBrandVectorScores = new ArrayList<>(); 31 List<SortBrandVectorScore> sortBrandVectorScores = new ArrayList<>();
27 for (SortBrand sortBrand : pageSortBrands) { 32 for (SortBrand sortBrand : pageSortBrands) {
28 - if (filterKeys.contains(sortBrand.key())) { 33 + if (filterSortBrandKeys.contains(sortBrand.key())) {
29 continue; 34 continue;
30 } 35 }
31 - List<Double> sortBrandVector = sortBrandVectorCacheBean.queryBrandSortVector(sortBrand,true); 36 + List<Double> sortBrandVector = sortBrandVectorCacheBean.queryBrandSortVector(sortBrand, true);
32 if (sortBrandVector == null || sortBrandVector.isEmpty()) { 37 if (sortBrandVector == null || sortBrandVector.isEmpty()) {
33 continue; 38 continue;
34 } 39 }
35 - double score = RnnVectorCalculator.calScore(userVectorList, sortBrandVector); 40 + double score = RnnVectorCalculator.calScore(userSortBrandVector, sortBrandVector);
36 sortBrandVectorScores.add(new SortBrandVectorScore(sortBrand, score)); 41 sortBrandVectorScores.add(new SortBrandVectorScore(sortBrand, score));
37 } 42 }
38 Collections.sort(sortBrandVectorScores, (o1, o2) -> o2.getScore().compareTo(o1.getScore()));//得分高的排在前面 43 Collections.sort(sortBrandVectorScores, (o1, o2) -> o2.getScore().compareTo(o1.getScore()));//得分高的排在前面
@@ -44,21 +49,25 @@ public class SortBrandVectorComponent { @@ -44,21 +49,25 @@ public class SortBrandVectorComponent {
44 return result; 49 return result;
45 } 50 }
46 51
47 - public List<SortBrand> queryW2VectorSortBrandList(List<SortBrand> pageSortBrands, Set<String> filterKeys, List<Double> userVectorList, int filterCount) {  
48 - if (userVectorList == null || userVectorList.isEmpty()) { 52 + public List<SortBrand> queryW2VectorSortBrandList(PagePersonalFactor pageFactor, Set<String> filterSortBrandKeys, List<Double> userBrandVector, List<Double> userSortBrandVector, int filterCount) {
  53 + if (userSortBrandVector == null || userSortBrandVector.isEmpty()) {
  54 + return new ArrayList<>();
  55 + }
  56 + List<SortBrand> pageSortBrands = pageFactor.getSortBrandList();
  57 + if (pageSortBrands == null || pageSortBrands.isEmpty()) {
49 return new ArrayList<>(); 58 return new ArrayList<>();
50 } 59 }
51 List<SortBrandVectorScore> sortBrandVectorScores = new ArrayList<>(); 60 List<SortBrandVectorScore> sortBrandVectorScores = new ArrayList<>();
52 - double userVectorListNorm = Word2VectorCalculator.getVectorListNorm(userVectorList); 61 + double userVectorListNorm = Word2VectorCalculator.getVectorListNorm(userSortBrandVector);
53 for (SortBrand sortBrand : pageSortBrands) { 62 for (SortBrand sortBrand : pageSortBrands) {
54 - if (filterKeys.contains(sortBrand.key())) { 63 + if (filterSortBrandKeys.contains(sortBrand.key())) {
55 continue; 64 continue;
56 } 65 }
57 - List<Double> sortBrandVector = sortBrandVectorCacheBean.queryBrandSortVector(sortBrand,false); 66 + List<Double> sortBrandVector = sortBrandVectorCacheBean.queryBrandSortVector(sortBrand, false);
58 if (sortBrandVector == null || sortBrandVector.isEmpty()) { 67 if (sortBrandVector == null || sortBrandVector.isEmpty()) {
59 continue; 68 continue;
60 } 69 }
61 - double score = Word2VectorCalculator.calScore(userVectorList, userVectorListNorm, sortBrandVector); 70 + double score = Word2VectorCalculator.calScore(userSortBrandVector, userVectorListNorm, sortBrandVector);
62 sortBrandVectorScores.add(new SortBrandVectorScore(sortBrand, score)); 71 sortBrandVectorScores.add(new SortBrandVectorScore(sortBrand, score));
63 } 72 }
64 Collections.sort(sortBrandVectorScores, (o1, o2) -> o2.getScore().compareTo(o1.getScore()));//得分高的排在前面 73 Collections.sort(sortBrandVectorScores, (o1, o2) -> o2.getScore().compareTo(o1.getScore()));//得分高的排在前面
@@ -7,31 +7,31 @@ package com.yoho.search.recall.scene.constants; @@ -7,31 +7,31 @@ package com.yoho.search.recall.scene.constants;
7 public class CacheTimeConstants { 7 public class CacheTimeConstants {
8 8
9 //通用召回的缓存 9 //通用召回的缓存
10 - public static final int COMMON_RECALL_STRATEGY_CACHE_TIME = 5 ; 10 + public static final int COMMON_RECALL_STRATEGY_CACHE_TIME = 5;
11 11
12 //SKN的的缓存 12 //SKN的的缓存
13 - public static final int SKN_RECALL_CACHE_TIME = 10 ; 13 + public static final int SKN_RECALL_CACHE_TIME = 10;
14 14
15 //品类+品牌的缓存 15 //品类+品牌的缓存
16 - public static final int SORT_BRAND_RECALL_STRATEGY_CACHE_TIME = 60 ; 16 + public static final int SORT_BRAND_RECALL_STRATEGY_CACHE_TIME = 60;
17 17
18 //SKN基本信息的缓存 18 //SKN基本信息的缓存
19 - public static final int SKN_BASE_INFO = 60 ; 19 + public static final int SKN_BASE_INFO = 60;
20 20
21 //SKN返回信息的缓存 21 //SKN返回信息的缓存
22 - public static final int SKN_RETURN_INFO = 2 ; 22 + public static final int SKN_RETURN_INFO = 3;
23 23
24 //用户召回结果的缓存 24 //用户召回结果的缓存
25 - public static final int USER_RECALL_SKN_LIST = 3 ; 25 + public static final int USER_RECALL_SKN_LIST = 3;
26 26
27 //页面skn的bitset缓存 27 //页面skn的bitset缓存
28 - public static final int PAGE_SKN_BITSET = 60 ; 28 + public static final int PAGE_SKN_BITSET = 60;
29 29
30 //页面个性化因子的缓存 30 //页面个性化因子的缓存
31 - public static final int PAGE_PERSIONAL_FACTOR = 60 ; 31 + public static final int PAGE_PERSIONAL_FACTOR = 60;
32 32
33 - public static final int CACHE_60_MINUTE = 60 ; 33 + public static final int CACHE_60_MINUTE = 60;
34 34
35 - public static final int CACHE_10_MINUTE = 10 ; 35 + public static final int CACHE_10_MINUTE = 10;
36 36
37 } 37 }
@@ -4,8 +4,11 @@ public class RecallCommonConstants { @@ -4,8 +4,11 @@ public class RecallCommonConstants {
4 4
5 public static final int maxRealTimeSortBrandCount = 15;//截取【品牌-品类】的数量-for召回【10->12】 5 public static final int maxRealTimeSortBrandCount = 15;//截取【品牌-品类】的数量-for召回【10->12】
6 6
7 - public static final int maxVectorSortBrandCount = 6;//截取【品牌-品类】的数量-for召回【10->6】  
8 -  
9 public static final int maxPredictSortBrandCount = 6;//截取【品牌-品类】的数量-for召回【10->6】 7 public static final int maxPredictSortBrandCount = 6;//截取【品牌-品类】的数量-for召回【10->6】
10 8
  9 + public static final int maxVectorRNNSortBrandCount = 6;//截取【品牌-品类】的数量-for召回【10->6】
  10 +
  11 + public static final int maxVectorW2SortBrandCount = 6;//截取【品牌-品类】的数量-for召回【10->6】
  12 +
  13 +
11 } 14 }
@@ -13,21 +13,15 @@ public class PagePersonalFactor implements Serializable { @@ -13,21 +13,15 @@ public class PagePersonalFactor implements Serializable {
13 private static final long serialVersionUID = 89030356435559223L; 13 private static final long serialVersionUID = 89030356435559223L;
14 14
15 private List<Integer> misortIds; 15 private List<Integer> misortIds;
  16 + private List<Integer> brandIds;
16 private List<SortBrand> sortBrandList; 17 private List<SortBrand> sortBrandList;
17 18
18 public PagePersonalFactor() { 19 public PagePersonalFactor() {
19 } 20 }
20 21
21 - public PagePersonalFactor(List<SortBrand> sortBrandList, List<Integer> misortIds) {  
22 - this.sortBrandList = sortBrandList; 22 + public PagePersonalFactor(List<Integer> misortIds, List<Integer> brandIds, List<SortBrand> sortBrandList) {
23 this.misortIds = misortIds; 23 this.misortIds = misortIds;
24 - }  
25 -  
26 - public List<SortBrand> getSortBrandList() {  
27 - return sortBrandList;  
28 - }  
29 -  
30 - public void setSortBrandList(List<SortBrand> sortBrandList) { 24 + this.brandIds = brandIds;
31 this.sortBrandList = sortBrandList; 25 this.sortBrandList = sortBrandList;
32 } 26 }
33 27
@@ -39,8 +33,19 @@ public class PagePersonalFactor implements Serializable { @@ -39,8 +33,19 @@ public class PagePersonalFactor implements Serializable {
39 this.misortIds = misortIds; 33 this.misortIds = misortIds;
40 } 34 }
41 35
42 - public int sortBrandListSize() {  
43 - return sortBrandList==null?0:sortBrandList.size(); 36 + public List<Integer> getBrandIds() {
  37 + return brandIds;
44 } 38 }
45 39
  40 + public void setBrandIds(List<Integer> brandIds) {
  41 + this.brandIds = brandIds;
  42 + }
  43 +
  44 + public List<SortBrand> getSortBrandList() {
  45 + return sortBrandList;
  46 + }
  47 +
  48 + public void setSortBrandList(List<SortBrand> sortBrandList) {
  49 + this.sortBrandList = sortBrandList;
  50 + }
46 } 51 }
@@ -8,62 +8,56 @@ import java.util.List; @@ -8,62 +8,56 @@ import java.util.List;
8 8
9 public class UserPersonalFactor { 9 public class UserPersonalFactor {
10 10
  11 + private List<Integer> recommendSknList;
  12 + private List<SortPriceAreas> sortPriceAreasList;
  13 +
11 private List<SortBrand> realTimeSortBrandList; 14 private List<SortBrand> realTimeSortBrandList;
12 private List<SortBrand> predictSortBrandList; 15 private List<SortBrand> predictSortBrandList;
13 - private List<SortBrand> vectorSortBrandList;  
14 - private List<SortPriceAreas> sortPriceAreasList;  
15 - private List<Integer> recommendSknList; 16 + private List<SortBrand> vectorRnnSortBrandList;
  17 + private List<SortBrand> vectorW2vSortBrandList;
16 18
17 public UserPersonalFactor() { 19 public UserPersonalFactor() {
  20 + this.recommendSknList = new ArrayList<>();
  21 + this.sortPriceAreasList = new ArrayList<>();
  22 +
18 this.realTimeSortBrandList = new ArrayList<>(); 23 this.realTimeSortBrandList = new ArrayList<>();
19 this.predictSortBrandList = new ArrayList<>(); 24 this.predictSortBrandList = new ArrayList<>();
20 - this.vectorSortBrandList = new ArrayList<>();  
21 - this.sortPriceAreasList = new ArrayList<>();  
22 - this.recommendSknList = new ArrayList<>(); 25 + this.vectorRnnSortBrandList = new ArrayList<>();
  26 + this.vectorW2vSortBrandList = new ArrayList<>();
23 } 27 }
24 28
25 - public UserPersonalFactor(List<SortBrand> realTimeSortBrandList, List<SortBrand> predictSortBrandList, List<SortBrand> vectorSortBrandList, List<SortPriceAreas> sortPriceAreasList, List<Integer> recommendSknList) {  
26 - this.realTimeSortBrandList = realTimeSortBrandList;  
27 - this.predictSortBrandList = predictSortBrandList;  
28 - this.vectorSortBrandList = vectorSortBrandList;  
29 - this.sortPriceAreasList = sortPriceAreasList; 29 + public UserPersonalFactor(List<Integer> recommendSknList, List<SortPriceAreas> sortPriceAreasList, List<SortBrand> realTimeSortBrandList, List<SortBrand> predictSortBrandList, List<SortBrand> vectorRnnSortBrandList, List<SortBrand> vectorW2vSortBrandList) {
30 this.recommendSknList = recommendSknList; 30 this.recommendSknList = recommendSknList;
31 - }  
32 -  
33 - public List<SortBrand> getRealTimeSortBrandList() {  
34 - return realTimeSortBrandList;  
35 - } 31 + this.sortPriceAreasList = sortPriceAreasList;
36 32
37 - public List<SortBrand> getPredictSortBrandList() {  
38 - return predictSortBrandList; 33 + this.realTimeSortBrandList = realTimeSortBrandList;
  34 + this.predictSortBrandList = predictSortBrandList;
  35 + this.vectorRnnSortBrandList = vectorRnnSortBrandList;
  36 + this.vectorW2vSortBrandList = vectorW2vSortBrandList;
39 } 37 }
40 38
41 - public List<SortBrand> getVectorSortBrandList() {  
42 - return vectorSortBrandList; 39 + public List<Integer> getRecommendSknList() {
  40 + return recommendSknList;
43 } 41 }
44 42
45 public List<SortPriceAreas> getSortPriceAreasList() { 43 public List<SortPriceAreas> getSortPriceAreasList() {
46 return sortPriceAreasList; 44 return sortPriceAreasList;
47 } 45 }
48 46
49 - public List<Integer> getRecommendSknList() {  
50 - return recommendSknList;  
51 - }  
52 -  
53 - public int getRealTimeSortBrandListSize() {  
54 - return realTimeSortBrandList == null ? 0 : realTimeSortBrandList.size(); 47 + public List<SortBrand> getRealTimeSortBrandList() {
  48 + return realTimeSortBrandList;
55 } 49 }
56 50
57 - public int getPredictSortBrandListSize() {  
58 - return predictSortBrandList == null ? 0 : predictSortBrandList.size(); 51 + public List<SortBrand> getPredictSortBrandList() {
  52 + return predictSortBrandList;
59 } 53 }
60 54
61 - public int getVectorSortBrandListSize() {  
62 - return vectorSortBrandList == null ? 0 : vectorSortBrandList.size(); 55 + public List<SortBrand> getVectorRnnSortBrandList() {
  56 + return vectorRnnSortBrandList;
63 } 57 }
64 58
65 - public int getSortPriceAreasListSize() {  
66 - return sortPriceAreasList == null ? 0 : sortPriceAreasList.size(); 59 + public List<SortBrand> getVectorW2vSortBrandList() {
  60 + return vectorW2vSortBrandList;
67 } 61 }
68 62
69 } 63 }
@@ -41,28 +41,25 @@ public class UserVectorSortBrandService { @@ -41,28 +41,25 @@ public class UserVectorSortBrandService {
41 int pageSize = MapUtils.getIntValue(paramMap, SearchRequestParams.PARAM_SEARCH_VIEWNUM, 20); 41 int pageSize = MapUtils.getIntValue(paramMap, SearchRequestParams.PARAM_SEARCH_VIEWNUM, 20);
42 UserRecallRequest userRecallRequest = userRecallRequestBuilder.buildUserRecallRequest(paramMap, pageSize); 42 UserRecallRequest userRecallRequest = userRecallRequestBuilder.buildUserRecallRequest(paramMap, pageSize);
43 UserPersonalFactor userPersonalFactor = queryUserPersionalFactorBean.queryPersionalFactor(userRecallRequest); 43 UserPersonalFactor userPersonalFactor = queryUserPersionalFactorBean.queryPersionalFactor(userRecallRequest);
44 -  
45 Map<String, Object> results = new HashMap<>(); 44 Map<String, Object> results = new HashMap<>();
46 //uid+udid 45 //uid+udid
47 results.put("uid", userRecallRequest.getUid()); 46 results.put("uid", userRecallRequest.getUid());
48 results.put("udid", userRecallRequest.getUdid()); 47 results.put("udid", userRecallRequest.getUdid());
49 -  
50 //推荐的skn 48 //推荐的skn
51 results.put("recommendSknList", userPersonalFactor.getRecommendSknList()); 49 results.put("recommendSknList", userPersonalFactor.getRecommendSknList());
52 -  
53 //用户价格带 50 //用户价格带
54 results.put("sortPriceAreasList", this.querySortPriceAreasList(userPersonalFactor.getSortPriceAreasList())); 51 results.put("sortPriceAreasList", this.querySortPriceAreasList(userPersonalFactor.getSortPriceAreasList()));
55 -  
56 //实时的品类品牌 52 //实时的品类品牌
57 results.put("realTimeSortBrandList", this.querySortBrands(userPersonalFactor.getRealTimeSortBrandList())); 53 results.put("realTimeSortBrandList", this.querySortBrands(userPersonalFactor.getRealTimeSortBrandList()));
58 //RNN预测的品类品牌 54 //RNN预测的品类品牌
59 results.put("predictSortBrandList", this.querySortBrands(userPersonalFactor.getPredictSortBrandList())); 55 results.put("predictSortBrandList", this.querySortBrands(userPersonalFactor.getPredictSortBrandList()));
60 - //向量预测的品类品牌  
61 - results.put("vectorSortBrandList", this.querySortBrands(userPersonalFactor.getVectorSortBrandList()));  
62 - 56 + //rnn向量预测的品类品牌
  57 + results.put("vectorRnnSortBrandList", this.querySortBrands(userPersonalFactor.getVectorRnnSortBrandList()));
  58 + //w2v向量预测的品类品牌
  59 + results.put("vectorW2vSortBrandList", this.querySortBrands(userPersonalFactor.getVectorW2vSortBrandList()));
63 return new SearchApiResult().setData(results); 60 return new SearchApiResult().setData(results);
64 } catch (Exception e) { 61 } catch (Exception e) {
65 - return new SearchApiResult(); 62 + return new SearchApiResult().setMessage(e.getMessage());
66 } 63 }
67 } 64 }
68 65