Authored by hugufei

新增一种召回

@@ -14,6 +14,7 @@ import com.yoho.search.service.recall.beans.strategy.StrategyEnum; @@ -14,6 +14,7 @@ import com.yoho.search.service.recall.beans.strategy.StrategyEnum;
14 import com.yoho.search.service.recall.beans.persional.PageSknCodeBitSetComponent; 14 import com.yoho.search.service.recall.beans.persional.PageSknCodeBitSetComponent;
15 import com.yoho.search.service.recall.beans.strategy.impls.IRecallSknStrategy; 15 import com.yoho.search.service.recall.beans.strategy.impls.IRecallSknStrategy;
16 import com.yoho.search.service.recall.beans.strategy.impls.RealTimeSimilarSknStrategy; 16 import com.yoho.search.service.recall.beans.strategy.impls.RealTimeSimilarSknStrategy;
  17 +import com.yoho.search.service.recall.beans.strategy.impls.RealTimeYoutuboSknStrategy;
17 import com.yoho.search.service.recall.beans.strategy.impls.RecommendSknStrategy; 18 import com.yoho.search.service.recall.beans.strategy.impls.RecommendSknStrategy;
18 import com.yoho.search.service.recall.config.RecallConfigService; 19 import com.yoho.search.service.recall.config.RecallConfigService;
19 import com.yoho.search.service.recall.models.common.ParamQueryFilter; 20 import com.yoho.search.service.recall.models.common.ParamQueryFilter;
@@ -75,21 +76,27 @@ public class SknRecallCacheBean { @@ -75,21 +76,27 @@ public class SknRecallCacheBean {
75 if (rtSimSknCount > 0 && userPersonalFactor.getRealTimeSimilarSknList() != null) { 76 if (rtSimSknCount > 0 && userPersonalFactor.getRealTimeSimilarSknList() != null) {
76 filterSknList.addAll(userPersonalFactor.getRealTimeSimilarSknList()); 77 filterSknList.addAll(userPersonalFactor.getRealTimeSimilarSknList());
77 } 78 }
  79 + //3、获取相似skn的配置
  80 + int youtubeSknCount = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.RT_YOUTUBE_SKN);
  81 + if (youtubeSknCount > 0 && userPersonalFactor.getRealTimeYoutubeSknList() != null) {
  82 + filterSknList.addAll(userPersonalFactor.getRealTimeYoutubeSknList());
  83 + }
78 if(filterSknList.isEmpty()){ 84 if(filterSknList.isEmpty()){
79 return new ArrayList<>(); 85 return new ArrayList<>();
80 } 86 }
81 - //3、执行查询 87 + //4、执行查询
82 List<Integer> filterSknResults; 88 List<Integer> filterSknResults;
83 if (recallWithCache) { 89 if (recallWithCache) {
84 filterSknResults = this.filterRecommendWithCache(userRecallRequest, filterSknList); 90 filterSknResults = this.filterRecommendWithCache(userRecallRequest, filterSknList);
85 } else { 91 } else {
86 filterSknResults = this.filterRecommedSknListByEs(userRecallRequest, filterSknList); 92 filterSknResults = this.filterRecommedSknListByEs(userRecallRequest, filterSknList);
87 } 93 }
88 - //3、构造结果 94 + //5、构造结果
89 List<RecallRequestResponse> results = new ArrayList<>(); 95 List<RecallRequestResponse> results = new ArrayList<>();
90 ParamQueryFilter paramQueryFilter = userRecallRequest.getParamQueryFilter(); 96 ParamQueryFilter paramQueryFilter = userRecallRequest.getParamQueryFilter();
91 results.addAll(this.buildResults(paramQueryFilter, userPersonalFactor.getRecommendSknList(), RecommendSknStrategy.class, filterSknResults, recSknCount)); 97 results.addAll(this.buildResults(paramQueryFilter, userPersonalFactor.getRecommendSknList(), RecommendSknStrategy.class, filterSknResults, recSknCount));
92 results.addAll(this.buildResults(paramQueryFilter, userPersonalFactor.getRealTimeSimilarSknList(), RealTimeSimilarSknStrategy.class, filterSknResults, rtSimSknCount)); 98 results.addAll(this.buildResults(paramQueryFilter, userPersonalFactor.getRealTimeSimilarSknList(), RealTimeSimilarSknStrategy.class, filterSknResults, rtSimSknCount));
  99 + results.addAll(this.buildResults(paramQueryFilter, userPersonalFactor.getRealTimeYoutubeSknList(), RealTimeYoutuboSknStrategy.class, filterSknResults, youtubeSknCount));
93 return results; 100 return results;
94 } catch (Exception e) { 101 } catch (Exception e) {
95 RECALL_NEW_LOGGER.error(e.getMessage(), e); 102 RECALL_NEW_LOGGER.error(e.getMessage(), e);
@@ -12,7 +12,7 @@ public class StrategyHelper { @@ -12,7 +12,7 @@ public class StrategyHelper {
12 } 12 }
13 13
14 public static List<StrategyEnum> getIntervalStrategyEnums() { 14 public static List<StrategyEnum> getIntervalStrategyEnums() {
15 - return Arrays.asList(StrategyEnum.REC_SKN, StrategyEnum.RT_SIM_SKN, StrategyEnum.DIRECT_TRAIN, StrategyEnum.ADD_FLOW, StrategyEnum.NEW_SHOP); 15 + return Arrays.asList(StrategyEnum.REC_SKN, StrategyEnum.RT_SIM_SKN,StrategyEnum.RT_YOUTUBE_SKN, StrategyEnum.DIRECT_TRAIN, StrategyEnum.ADD_FLOW, StrategyEnum.NEW_SHOP);
16 } 16 }
17 17
18 } 18 }
@@ -2,7 +2,7 @@ package com.yoho.search.service.recall.beans.persional; @@ -2,7 +2,7 @@ package com.yoho.search.service.recall.beans.persional;
2 2
3 import com.yoho.search.core.personalized.models.SortBrand; 3 import com.yoho.search.core.personalized.models.SortBrand;
4 import com.yoho.search.core.personalized.models.SortPriceAreas; 4 import com.yoho.search.core.personalized.models.SortPriceAreas;
5 -import com.yoho.search.core.personalized.models.UserPersonalFactorRspNew; 5 +import com.yoho.search.core.personalized.models.UserPersonalFactorRsp;
6 import com.yoho.search.service.recall.beans.strategy.SortBrandType; 6 import com.yoho.search.service.recall.beans.strategy.SortBrandType;
7 import com.yoho.search.service.recall.beans.vector.SortBrandVectorComponent; 7 import com.yoho.search.service.recall.beans.vector.SortBrandVectorComponent;
8 import com.yoho.search.service.recall.config.RecallConfigService; 8 import com.yoho.search.service.recall.config.RecallConfigService;
@@ -14,7 +14,10 @@ import org.slf4j.LoggerFactory; @@ -14,7 +14,10 @@ import org.slf4j.LoggerFactory;
14 import org.springframework.beans.factory.annotation.Autowired; 14 import org.springframework.beans.factory.annotation.Autowired;
15 import org.springframework.stereotype.Component; 15 import org.springframework.stereotype.Component;
16 16
17 -import java.util.*; 17 +import java.util.ArrayList;
  18 +import java.util.HashSet;
  19 +import java.util.List;
  20 +import java.util.Set;
18 21
19 @Component 22 @Component
20 public class QueryUserPersionalFactorBean { 23 public class QueryUserPersionalFactorBean {
@@ -53,7 +56,7 @@ public class QueryUserPersionalFactorBean { @@ -53,7 +56,7 @@ public class QueryUserPersionalFactorBean {
53 RECALL_NEW_LOGGER.info("QueryUserPersionalFactorBean[1]:queryPagePersionalFactor. uid is[{}],udid is[{}], cost is[{}]] ms", uid, udid, cost); 56 RECALL_NEW_LOGGER.info("QueryUserPersionalFactorBean[1]:queryPagePersionalFactor. uid is[{}],udid is[{}], cost is[{}]] ms", uid, udid, cost);
54 //2、获取用户的个性化因子 57 //2、获取用户的个性化因子
55 begin = System.currentTimeMillis(); 58 begin = System.currentTimeMillis();
56 - UserPersonalFactorRspNew userFactor = userComponent.queryUserPersionalFactor(userRecallRequest.getUid(), userRecallRequest.getUdid(), pageFactor.getMisortIds()); 59 + UserPersonalFactorRsp userFactor = userComponent.queryUserPersionalFactor(userRecallRequest.getUid(), userRecallRequest.getUdid(), pageFactor.getMisortIds());
57 cost = System.currentTimeMillis() - begin; 60 cost = System.currentTimeMillis() - begin;
58 RECALL_NEW_LOGGER.info("QueryUserPersionalFactorBean[2]:queryUserPersionalFactor. uid is[{}],udid is[{}], cost is[{}]", uid, udid, cost); 61 RECALL_NEW_LOGGER.info("QueryUserPersionalFactorBean[2]:queryUserPersionalFactor. uid is[{}],udid is[{}], cost is[{}]", uid, udid, cost);
59 //3、构造结果 62 //3、构造结果
@@ -68,15 +71,15 @@ public class QueryUserPersionalFactorBean { @@ -68,15 +71,15 @@ public class QueryUserPersionalFactorBean {
68 } 71 }
69 } 72 }
70 73
71 - private UserPersonalFactor buildUserPersonalFactor(int pageId, PagePersonalFactor pageFactor, UserPersonalFactorRspNew userFactor) { 74 + private UserPersonalFactor buildUserPersonalFactor(int pageId, PagePersonalFactor pageFactor, UserPersonalFactorRsp userFactor) {
72 //1、构造品类价格带 75 //1、构造品类价格带
73 List<SortPriceAreas> sortPriceAreasList = this.getSortPriceAreasListWithSort(userFactor, pageFactor); 76 List<SortPriceAreas> sortPriceAreasList = this.getSortPriceAreasListWithSort(userFactor, pageFactor);
74 //2、构造推荐的skn列表 77 //2、构造推荐的skn列表
75 List<Integer> recommendSknList = userFactor.getRecommendSknList(); 78 List<Integer> recommendSknList = userFactor.getRecommendSknList();
76 List<Integer> realTimeSimilarSknList = userFactor.getRealTimeSimilarSknList(); 79 List<Integer> realTimeSimilarSknList = userFactor.getRealTimeSimilarSknList();
  80 + List<Integer> realTimeYoutubeSknList = userFactor.getRealTimeYoutubeSknList();
77 //TODO remove 81 //TODO remove
78 //realTimeSimilarSknList.addAll(Arrays.asList(50003513,50013179,50018239,50023799)); 82 //realTimeSimilarSknList.addAll(Arrays.asList(50003513,50013179,50018239,50023799));
79 -  
80 //3、获取页面中存在的所有的key 83 //3、获取页面中存在的所有的key
81 Set<String> pageSortBrandKeys = new HashSet<>(); 84 Set<String> pageSortBrandKeys = new HashSet<>();
82 for (SortBrand pageSortBrand : pageFactor.getSortBrandList()) { 85 for (SortBrand pageSortBrand : pageFactor.getSortBrandList()) {
@@ -106,11 +109,11 @@ public class QueryUserPersionalFactorBean { @@ -106,11 +109,11 @@ public class QueryUserPersionalFactorBean {
106 filterSortBrandKeys.add(existSortBrand.key()); 109 filterSortBrandKeys.add(existSortBrand.key());
107 } 110 }
108 //8、构造个性化结果[如果个性化结果为空,则取配置的品类品牌数据] 111 //8、构造个性化结果[如果个性化结果为空,则取配置的品类品牌数据]
109 - UserPersonalFactor userPersonalFactor = new UserPersonalFactor(recommendSknList, realTimeSimilarSknList, sortPriceAreasList, realTimeSortBrandList, vectorRnnSortBrandList, vectorW2vSortBrandList); 112 + UserPersonalFactor userPersonalFactor = new UserPersonalFactor(recommendSknList, realTimeSimilarSknList,realTimeYoutubeSknList, sortPriceAreasList, realTimeSortBrandList, vectorRnnSortBrandList, vectorW2vSortBrandList);
110 if (userPersonalFactor.isUserPersonalFactorEmpty()) { 113 if (userPersonalFactor.isUserPersonalFactorEmpty()) {
111 this.fillConfigSortBrandList(userPersonalFactor, pageId, pageFactor, pageSortBrandKeys, filterSortBrandKeys); 114 this.fillConfigSortBrandList(userPersonalFactor, pageId, pageFactor, pageSortBrandKeys, filterSortBrandKeys);
112 } 115 }
113 - //10、返回最终结果 116 + //9、返回最终结果
114 return userPersonalFactor; 117 return userPersonalFactor;
115 } 118 }
116 119
@@ -147,7 +150,7 @@ public class QueryUserPersionalFactorBean { @@ -147,7 +150,7 @@ public class QueryUserPersionalFactorBean {
147 * @param userFactorNew 150 * @param userFactorNew
148 * @return 151 * @return
149 */ 152 */
150 - private List<SortPriceAreas> getSortPriceAreasListWithSort(UserPersonalFactorRspNew userFactorNew, PagePersonalFactor pageFactor) { 153 + private List<SortPriceAreas> getSortPriceAreasListWithSort(UserPersonalFactorRsp userFactorNew, PagePersonalFactor pageFactor) {
151 List<SortPriceAreas> sortPriceAreas = userFactorNew.getSortPriceAreasList(); 154 List<SortPriceAreas> sortPriceAreas = userFactorNew.getSortPriceAreasList();
152 if (sortPriceAreas == null || sortPriceAreas.isEmpty()) { 155 if (sortPriceAreas == null || sortPriceAreas.isEmpty()) {
153 return new ArrayList<>(); 156 return new ArrayList<>();
1 package com.yoho.search.service.recall.beans.persional; 1 package com.yoho.search.service.recall.beans.persional;
2 2
3 -import com.yoho.search.core.personalized.models.UserPersonalFactorRspNew; 3 +import com.yoho.search.core.personalized.models.UserPersonalFactorRsp;
4 import com.yoho.search.core.personalized.service.BidataServiceCaller; 4 import com.yoho.search.core.personalized.service.BidataServiceCaller;
5 import org.slf4j.Logger; 5 import org.slf4j.Logger;
6 import org.slf4j.LoggerFactory; 6 import org.slf4j.LoggerFactory;
@@ -25,16 +25,24 @@ public class UserPersionalFactorComponent { @@ -25,16 +25,24 @@ public class UserPersionalFactorComponent {
25 * @param udid 25 * @param udid
26 * @return 26 * @return
27 */ 27 */
28 - public UserPersonalFactorRspNew queryUserPersionalFactor(int uid, String udid, List<Integer> misortIds) { 28 + public UserPersonalFactorRsp queryUserPersionalFactor(int uid, String udid, List<Integer> misortIds) {
29 try { 29 try {
30 - UserPersonalFactorRspNew rsp = bidataServiceCaller.queryUserPersionalFactor(uid, udid, misortIds); 30 + UserPersonalFactorRsp rsp = bidataServiceCaller.queryUserPersionalFactor(uid, udid, misortIds);
31 if (rsp == null) { 31 if (rsp == null) {
32 - rsp = new UserPersonalFactorRspNew(); 32 + rsp = new UserPersonalFactorRsp();
33 } 33 }
34 - //skn 34 + //recommendSknList
35 if (rsp.getRecommendSknList() == null) { 35 if (rsp.getRecommendSknList() == null) {
36 rsp.setRecommendSknList(new ArrayList<>()); 36 rsp.setRecommendSknList(new ArrayList<>());
37 } 37 }
  38 + //realTimeSimilarSknList
  39 + if (rsp.getRealTimeSimilarSknList() == null) {
  40 + rsp.setRealTimeSimilarSknList(new ArrayList<>());
  41 + }
  42 + //realTimeYoutubeSknList
  43 + if (rsp.getRealTimeYoutubeSknList() == null) {
  44 + rsp.setRealTimeYoutubeSknList(new ArrayList<>());
  45 + }
38 //价格带 46 //价格带
39 if (rsp.getSortPriceAreasList() == null) { 47 if (rsp.getSortPriceAreasList() == null) {
40 rsp.setSortPriceAreasList(new ArrayList<>()); 48 rsp.setSortPriceAreasList(new ArrayList<>());
@@ -60,7 +68,7 @@ public class UserPersionalFactorComponent { @@ -60,7 +68,7 @@ public class UserPersionalFactorComponent {
60 return rsp; 68 return rsp;
61 } catch (Exception e) { 69 } catch (Exception e) {
62 RECALL_NEW_LOGGER.error(e.getMessage(), e); 70 RECALL_NEW_LOGGER.error(e.getMessage(), e);
63 - return new UserPersonalFactorRspNew(); 71 + return new UserPersonalFactorRsp();
64 } 72 }
65 } 73 }
66 74
@@ -6,8 +6,9 @@ public enum StrategyEnum { @@ -6,8 +6,9 @@ public enum StrategyEnum {
6 DIRECT_TRAIN(109),//直通车 6 DIRECT_TRAIN(109),//直通车
7 REC_SKN(108),//实时推荐的skn 7 REC_SKN(108),//实时推荐的skn
8 RT_SIM_SKN(107),//实时推荐的skn的相似skn 8 RT_SIM_SKN(107),//实时推荐的skn的相似skn
9 - ADD_FLOW(106),//流量补偿  
10 - NEW_SHOP(105),//新开店铺 9 + RT_YOUTUBE_SKN(106),//实时推荐的skn的相似skn
  10 + ADD_FLOW(105),//流量补偿
  11 + NEW_SHOP(104),//新开店铺
11 12
12 REC_S_B_NEW(89),//实时的品牌+品类的新品 13 REC_S_B_NEW(89),//实时的品牌+品类的新品
13 REC_S_B_PROMOTION(88),//实时的品牌+品类的新开促销 14 REC_S_B_PROMOTION(88),//实时的品牌+品类的新开促销
  1 +package com.yoho.search.service.recall.beans.strategy.impls;
  2 +
  3 +import com.yoho.search.service.recall.beans.strategy.StrategyEnum;
  4 +
  5 +public class RealTimeYoutuboSknStrategy extends IRecallSknStrategy {
  6 +
  7 + public RealTimeYoutuboSknStrategy(Integer recommendSkn) {
  8 + super(recommendSkn);
  9 + }
  10 +
  11 + @Override
  12 + public StrategyEnum strategtEnum() {
  13 + return StrategyEnum.RT_YOUTUBE_SKN;
  14 + }
  15 +
  16 +}
@@ -9,6 +9,8 @@ public class RecallConfigConstants { @@ -9,6 +9,8 @@ public class RecallConfigConstants {
9 public static final String DIRECT_TRAIN = "DIRECT_TRAIN"; 9 public static final String DIRECT_TRAIN = "DIRECT_TRAIN";
10 public static final String REC_SKN = "REC_SKN"; 10 public static final String REC_SKN = "REC_SKN";
11 public static final String RT_SIM_SKN = "RT_SIM_SKN"; 11 public static final String RT_SIM_SKN = "RT_SIM_SKN";
  12 + public static final String RT_YOUTUBE_SKN = "RT_YOUTUBE_SKN";
  13 +
12 public static final String ADD_FLOW = "ADD_FLOW"; 14 public static final String ADD_FLOW = "ADD_FLOW";
13 public static final String NEW_SHOP = "NEW_SHOP"; 15 public static final String NEW_SHOP = "NEW_SHOP";
14 16
@@ -73,6 +73,9 @@ public class RecallConfigService { @@ -73,6 +73,9 @@ public class RecallConfigService {
73 if (strategyEnum.equals(StrategyEnum.RT_SIM_SKN)) { 73 if (strategyEnum.equals(StrategyEnum.RT_SIM_SKN)) {
74 return RecallConfigConstants.RT_SIM_SKN; 74 return RecallConfigConstants.RT_SIM_SKN;
75 } 75 }
  76 + if (strategyEnum.equals(StrategyEnum.RT_YOUTUBE_SKN)) {
  77 + return RecallConfigConstants.RT_YOUTUBE_SKN;
  78 + }
76 if (strategyEnum.equals(StrategyEnum.DIRECT_TRAIN)) { 79 if (strategyEnum.equals(StrategyEnum.DIRECT_TRAIN)) {
77 return RecallConfigConstants.DIRECT_TRAIN; 80 return RecallConfigConstants.DIRECT_TRAIN;
78 } 81 }
@@ -11,6 +11,8 @@ public class UserPersonalFactor { @@ -11,6 +11,8 @@ public class UserPersonalFactor {
11 11
12 private List<Integer> recommendSknList; 12 private List<Integer> recommendSknList;
13 private List<Integer> realTimeSimilarSknList; 13 private List<Integer> realTimeSimilarSknList;
  14 + private List<Integer> realTimeYoutubeSknList;
  15 +
14 private List<SortPriceAreas> sortPriceAreasList; 16 private List<SortPriceAreas> sortPriceAreasList;
15 17
16 private List<SortBrand> realTimeSortBrandList; 18 private List<SortBrand> realTimeSortBrandList;
@@ -21,6 +23,8 @@ public class UserPersonalFactor { @@ -21,6 +23,8 @@ public class UserPersonalFactor {
21 public UserPersonalFactor() { 23 public UserPersonalFactor() {
22 this.recommendSknList = new ArrayList<>(); 24 this.recommendSknList = new ArrayList<>();
23 this.realTimeSimilarSknList = new ArrayList<>(); 25 this.realTimeSimilarSknList = new ArrayList<>();
  26 + this.realTimeYoutubeSknList = new ArrayList<>();
  27 +
24 this.sortPriceAreasList = new ArrayList<>(); 28 this.sortPriceAreasList = new ArrayList<>();
25 29
26 this.realTimeSortBrandList = new ArrayList<>(); 30 this.realTimeSortBrandList = new ArrayList<>();
@@ -29,9 +33,10 @@ public class UserPersonalFactor { @@ -29,9 +33,10 @@ public class UserPersonalFactor {
29 this.configSortBrandList = new ArrayList<>(); 33 this.configSortBrandList = new ArrayList<>();
30 } 34 }
31 35
32 - public UserPersonalFactor(List<Integer> recommendSknList, List<Integer> realTimeSimilarSknList, List<SortPriceAreas> sortPriceAreasList, List<SortBrand> realTimeSortBrandList, List<SortBrand> vectorRnnSortBrandList, List<SortBrand> vectorW2vSortBrandList) { 36 + public UserPersonalFactor(List<Integer> recommendSknList, List<Integer> realTimeSimilarSknList,List<Integer> realTimeYoutubeSknList, List<SortPriceAreas> sortPriceAreasList, List<SortBrand> realTimeSortBrandList, List<SortBrand> vectorRnnSortBrandList, List<SortBrand> vectorW2vSortBrandList) {
33 this.recommendSknList = recommendSknList; 37 this.recommendSknList = recommendSknList;
34 this.realTimeSimilarSknList = realTimeSimilarSknList; 38 this.realTimeSimilarSknList = realTimeSimilarSknList;
  39 + this.realTimeYoutubeSknList = realTimeYoutubeSknList;
35 this.sortPriceAreasList = sortPriceAreasList; 40 this.sortPriceAreasList = sortPriceAreasList;
36 this.realTimeSortBrandList = realTimeSortBrandList; 41 this.realTimeSortBrandList = realTimeSortBrandList;
37 this.vectorRnnSortBrandList = vectorRnnSortBrandList; 42 this.vectorRnnSortBrandList = vectorRnnSortBrandList;
@@ -62,6 +67,9 @@ public class UserPersonalFactor { @@ -62,6 +67,9 @@ public class UserPersonalFactor {
62 return vectorW2vSortBrandList; 67 return vectorW2vSortBrandList;
63 } 68 }
64 69
  70 + public List<Integer> getRealTimeYoutubeSknList() {
  71 + return realTimeYoutubeSknList;
  72 + }
65 73
66 /** 74 /**
67 * 判断用户个性化数据是否都为空 75 * 判断用户个性化数据是否都为空
@@ -74,6 +82,9 @@ public class UserPersonalFactor { @@ -74,6 +82,9 @@ public class UserPersonalFactor {
74 if(!CollectionUtils.isEmpty(this.realTimeSimilarSknList)){ 82 if(!CollectionUtils.isEmpty(this.realTimeSimilarSknList)){
75 return false; 83 return false;
76 } 84 }
  85 + if(!CollectionUtils.isEmpty(this.realTimeYoutubeSknList)){
  86 + return false;
  87 + }
77 if(!CollectionUtils.isEmpty(this.realTimeSortBrandList)){ 88 if(!CollectionUtils.isEmpty(this.realTimeSortBrandList)){
78 return false; 89 return false;
79 } 90 }
@@ -5,7 +5,7 @@ import com.alibaba.fastjson.JSONArray; @@ -5,7 +5,7 @@ import com.alibaba.fastjson.JSONArray;
5 import com.alibaba.fastjson.JSONObject; 5 import com.alibaba.fastjson.JSONObject;
6 import com.alibaba.fastjson.TypeReference; 6 import com.alibaba.fastjson.TypeReference;
7 import com.yoho.search.core.personalized.models.SortBrand; 7 import com.yoho.search.core.personalized.models.SortBrand;
8 -import com.yoho.search.core.personalized.models.UserPersonalFactorRspNew; 8 +import com.yoho.search.core.personalized.models.UserPersonalFactorRsp;
9 import com.yoho.search.models.SearchApiResult; 9 import com.yoho.search.models.SearchApiResult;
10 import com.yoho.search.common.SearchRequestParams; 10 import com.yoho.search.common.SearchRequestParams;
11 import org.apache.commons.collections.MapUtils; 11 import org.apache.commons.collections.MapUtils;
@@ -51,7 +51,7 @@ public class PageSelectionsBrandsService { @@ -51,7 +51,7 @@ public class PageSelectionsBrandsService {
51 String udid = MapUtils.getString(paramMap, "udid", ""); 51 String udid = MapUtils.getString(paramMap, "udid", "");
52 int recommendBrandCount = Integer.parseInt(paramMap.getOrDefault(SearchRequestParams.PARAM_SEARCH_VIEWNUM, "8")); 52 int recommendBrandCount = Integer.parseInt(paramMap.getOrDefault(SearchRequestParams.PARAM_SEARCH_VIEWNUM, "8"));
53 JSONArray recBrands = new JSONArray(recommendBrandCount); 53 JSONArray recBrands = new JSONArray(recommendBrandCount);
54 - UserPersonalFactorRspNew userFactor = userPersionalFactorComponent.queryUserPersionalFactor(uid, udid, null); 54 + UserPersonalFactorRsp userFactor = userPersionalFactorComponent.queryUserPersionalFactor(uid, udid, null);
55 List<Integer> brandIds = new ArrayList<>(); 55 List<Integer> brandIds = new ArrayList<>();
56 if (userFactor != null && userFactor.getRealTimeSortBrandList()!=null) { 56 if (userFactor != null && userFactor.getRealTimeSortBrandList()!=null) {
57 List<SortBrand> sortBrandList = new ArrayList<>(userFactor.getRealTimeSortBrandList()); 57 List<SortBrand> sortBrandList = new ArrayList<>(userFactor.getRealTimeSortBrandList());
@@ -3,7 +3,7 @@ package com.yoho.search.service.scene.recommend; @@ -3,7 +3,7 @@ package com.yoho.search.service.scene.recommend;
3 import com.yoho.search.base.helper.RnnVectorCalculator; 3 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.core.personalized.models.SortBrand; 5 import com.yoho.search.core.personalized.models.SortBrand;
6 -import com.yoho.search.core.personalized.models.UserPersonalFactorRspNew; 6 +import com.yoho.search.core.personalized.models.UserPersonalFactorRsp;
7 import com.yoho.search.service.recall.beans.vector.BrandVectorCacheBean; 7 import com.yoho.search.service.recall.beans.vector.BrandVectorCacheBean;
8 import com.yoho.search.service.scene.shopbrand.ShopBrandRelation; 8 import com.yoho.search.service.scene.shopbrand.ShopBrandRelation;
9 import com.yoho.search.service.scene.shopbrand.ShopBrandRelationCacheComponent; 9 import com.yoho.search.service.scene.shopbrand.ShopBrandRelationCacheComponent;
@@ -24,24 +24,24 @@ public class PersionalShopService { @@ -24,24 +24,24 @@ public class PersionalShopService {
24 24
25 private static final Logger logger = LoggerFactory.getLogger(PersionalShopService.class); 25 private static final Logger logger = LoggerFactory.getLogger(PersionalShopService.class);
26 26
27 - public List<Integer> buildPersionalShopIdsByBrandIds(Map<String, String> paramMap, List<Integer> brandIds, UserPersonalFactorRspNew userPersonalFactorRspNew) { 27 + public List<Integer> buildPersionalShopIdsByBrandIds(Map<String, String> paramMap, List<Integer> brandIds, UserPersonalFactorRsp userPersonalFactorRsp) {
28 List<ShopBrandRelation> relations = shopBrandRelationCacheComponent.queryActivityShopBrandList(paramMap, brandIds); 28 List<ShopBrandRelation> relations = shopBrandRelationCacheComponent.queryActivityShopBrandList(paramMap, brandIds);
29 - List<Integer> shopIds = buildPersionalShopIds(relations, userPersonalFactorRspNew); 29 + List<Integer> shopIds = buildPersionalShopIds(relations, userPersonalFactorRsp);
30 return shopIds == null ? new ArrayList<>() : shopIds; 30 return shopIds == null ? new ArrayList<>() : shopIds;
31 } 31 }
32 32
33 - public List<Integer> buildPersionalShopIds(List<ShopBrandRelation> shopBrandList, UserPersonalFactorRspNew userPersonalFactorRspNew) { 33 + public List<Integer> buildPersionalShopIds(List<ShopBrandRelation> shopBrandList, UserPersonalFactorRsp userPersonalFactorRsp) {
34 //1、获取品牌-店铺的对应关系 34 //1、获取品牌-店铺的对应关系
35 Map<Integer, Integer> brandId2ShopIdMap = new HashMap<>(); 35 Map<Integer, Integer> brandId2ShopIdMap = new HashMap<>();
36 for (ShopBrandRelation shopBrandRelation : shopBrandList) { 36 for (ShopBrandRelation shopBrandRelation : shopBrandList) {
37 brandId2ShopIdMap.put(shopBrandRelation.getBrandId(), shopBrandRelation.getShopId()); 37 brandId2ShopIdMap.put(shopBrandRelation.getBrandId(), shopBrandRelation.getShopId());
38 } 38 }
39 //2、获取实时推荐的品牌 39 //2、获取实时推荐的品牌
40 - List<Integer> recBrandIds = this.getRecBrandIds(userPersonalFactorRspNew); 40 + List<Integer> recBrandIds = this.getRecBrandIds(userPersonalFactorRsp);
41 41
42 //3、计算店铺得分并排序 42 //3、计算店铺得分并排序
43 - List<Double> brandVector = userPersonalFactorRspNew.getBrandVector();  
44 - List<Double> brandVectorW2v = userPersonalFactorRspNew.getBrandVectorW2v(); 43 + List<Double> brandVector = userPersonalFactorRsp.getBrandVector();
  44 + List<Double> brandVectorW2v = userPersonalFactorRsp.getBrandVectorW2v();
45 if (brandVectorW2v != null && !brandVectorW2v.isEmpty()) { 45 if (brandVectorW2v != null && !brandVectorW2v.isEmpty()) {
46 this.calScore(shopBrandList, brandVectorW2v, false); 46 this.calScore(shopBrandList, brandVectorW2v, false);
47 } else { 47 } else {
@@ -72,10 +72,10 @@ public class PersionalShopService { @@ -72,10 +72,10 @@ public class PersionalShopService {
72 return shopIds; 72 return shopIds;
73 } 73 }
74 74
75 - private List<Integer> getRecBrandIds(UserPersonalFactorRspNew userPersonalFactorRspNew) { 75 + private List<Integer> getRecBrandIds(UserPersonalFactorRsp userPersonalFactorRsp) {
76 List<Integer> realBrandId = new ArrayList<>(); 76 List<Integer> realBrandId = new ArrayList<>();
77 try { 77 try {
78 - List<SortBrand> realTimeSortBrand = userPersonalFactorRspNew.getRealTimeSortBrandList(); 78 + List<SortBrand> realTimeSortBrand = userPersonalFactorRsp.getRealTimeSortBrandList();
79 for (SortBrand sortBrand : realTimeSortBrand) { 79 for (SortBrand sortBrand : realTimeSortBrand) {
80 if (!realBrandId.contains(sortBrand.getBrandId())) { 80 if (!realBrandId.contains(sortBrand.getBrandId())) {
81 realBrandId.add(sortBrand.getBrandId()); 81 realBrandId.add(sortBrand.getBrandId());
@@ -11,7 +11,7 @@ import com.yoho.search.common.SearchRequestParams; @@ -11,7 +11,7 @@ import com.yoho.search.common.SearchRequestParams;
11 import com.yoho.search.core.es.agg.IAggregation; 11 import com.yoho.search.core.es.agg.IAggregation;
12 import com.yoho.search.core.es.model.SearchParam; 12 import com.yoho.search.core.es.model.SearchParam;
13 import com.yoho.search.core.personalized.models.SortBrand; 13 import com.yoho.search.core.personalized.models.SortBrand;
14 -import com.yoho.search.core.personalized.models.UserPersonalFactorRspNew; 14 +import com.yoho.search.core.personalized.models.UserPersonalFactorRsp;
15 import com.yoho.search.models.SearchApiResult; 15 import com.yoho.search.models.SearchApiResult;
16 import com.yoho.search.service.aggregations.AggregationsService; 16 import com.yoho.search.service.aggregations.AggregationsService;
17 import com.yoho.search.service.aggregations.impls.ProductAnalysisBrandAggregation; 17 import com.yoho.search.service.aggregations.impls.ProductAnalysisBrandAggregation;
@@ -159,7 +159,7 @@ public class RecommendOnProductAnalysisService { @@ -159,7 +159,7 @@ public class RecommendOnProductAnalysisService {
159 159
160 //获取用户有行为的品类 排序sort, RealTimeSort加分放前面 160 //获取用户有行为的品类 排序sort, RealTimeSort加分放前面
161 private List<Integer> reorderSortOnUserPersonalSort(final List<Integer> sortIds, final Map<Integer, Integer> miSort2SortMap, int uid, String udid) { 161 private List<Integer> reorderSortOnUserPersonalSort(final List<Integer> sortIds, final Map<Integer, Integer> miSort2SortMap, int uid, String udid) {
162 - UserPersonalFactorRspNew userFactor = getUserPersonalFactor(uid, udid); 162 + UserPersonalFactorRsp userFactor = getUserPersonalFactor(uid, udid);
163 if (userFactor == null || CollectionUtils.isEmpty(userFactor.getRealTimeSortBrandList())) { 163 if (userFactor == null || CollectionUtils.isEmpty(userFactor.getRealTimeSortBrandList())) {
164 return sortIds; 164 return sortIds;
165 } 165 }
@@ -233,7 +233,7 @@ public class RecommendOnProductAnalysisService { @@ -233,7 +233,7 @@ public class RecommendOnProductAnalysisService {
233 return new ArrayList<>(); 233 return new ArrayList<>();
234 } 234 }
235 Map<String, String> productIndexParamsWithDefault = genProductIndexParamsWithDefault(paramMap); 235 Map<String, String> productIndexParamsWithDefault = genProductIndexParamsWithDefault(paramMap);
236 - UserPersonalFactorRspNew userFactor = getUserPersonalFactor(uid, udid); 236 + UserPersonalFactorRsp userFactor = getUserPersonalFactor(uid, udid);
237 List<Integer> shopIds = persionalShopService.buildPersionalShopIdsByBrandIds(productIndexParamsWithDefault, aggBestBrandIds, userFactor); 237 List<Integer> shopIds = persionalShopService.buildPersionalShopIdsByBrandIds(productIndexParamsWithDefault, aggBestBrandIds, userFactor);
238 List<Integer> shopIdList = checkShopIds(shopIds); 238 List<Integer> shopIdList = checkShopIds(shopIds);
239 return shopIdList == null ? new ArrayList<>() : shopIdList; 239 return shopIdList == null ? new ArrayList<>() : shopIdList;
@@ -349,7 +349,7 @@ public class RecommendOnProductAnalysisService { @@ -349,7 +349,7 @@ public class RecommendOnProductAnalysisService {
349 try { 349 try {
350 int uid = MapUtils.getIntValue(paramMap, "uid", 0); 350 int uid = MapUtils.getIntValue(paramMap, "uid", 0);
351 String udid = MapUtils.getString(paramMap, "udid", ""); 351 String udid = MapUtils.getString(paramMap, "udid", "");
352 - UserPersonalFactorRspNew userFactor = getUserPersonalFactor(uid, udid); 352 + UserPersonalFactorRsp userFactor = getUserPersonalFactor(uid, udid);
353 if (userFactor == null || CollectionUtils.isEmpty(userFactor.getRealTimeSortBrandList())) { 353 if (userFactor == null || CollectionUtils.isEmpty(userFactor.getRealTimeSortBrandList())) {
354 return new ArrayList<>(); 354 return new ArrayList<>();
355 } 355 }
@@ -459,11 +459,11 @@ public class RecommendOnProductAnalysisService { @@ -459,11 +459,11 @@ public class RecommendOnProductAnalysisService {
459 } 459 }
460 460
461 //获取用户行为 461 //获取用户行为
462 - private UserPersonalFactorRspNew getUserPersonalFactor(int uid, String udid) { 462 + private UserPersonalFactorRsp getUserPersonalFactor(int uid, String udid) {
463 if (uid > 0 || StringUtils.isNotBlank(udid)) { 463 if (uid > 0 || StringUtils.isNotBlank(udid)) {
464 return userComponent.queryUserPersionalFactor(uid, udid, null); 464 return userComponent.queryUserPersionalFactor(uid, udid, null);
465 } 465 }
466 - return new UserPersonalFactorRspNew(); 466 + return new UserPersonalFactorRsp();
467 } 467 }
468 468
469 public static void main(String[] args) { 469 public static void main(String[] args) {
@@ -2,7 +2,7 @@ package com.yoho.search.service.scene.recommend.activity; @@ -2,7 +2,7 @@ package com.yoho.search.service.scene.recommend.activity;
2 2
3 import com.yoho.search.base.utils.SearchCollectionUtils; 3 import com.yoho.search.base.utils.SearchCollectionUtils;
4 import com.yoho.search.common.SearchRequestParams; 4 import com.yoho.search.common.SearchRequestParams;
5 -import com.yoho.search.core.personalized.models.UserPersonalFactorRspNew; 5 +import com.yoho.search.core.personalized.models.UserPersonalFactorRsp;
6 import com.yoho.search.models.SearchApiResult; 6 import com.yoho.search.models.SearchApiResult;
7 import com.yoho.search.service.index.ShopsIndexBaseService; 7 import com.yoho.search.service.index.ShopsIndexBaseService;
8 import com.yoho.search.service.recall.beans.persional.UserPersionalFactorComponent; 8 import com.yoho.search.service.recall.beans.persional.UserPersionalFactorComponent;
@@ -41,9 +41,9 @@ public class ActivityRecommendShopService { @@ -41,9 +41,9 @@ public class ActivityRecommendShopService {
41 //2、查询用户的品牌向量 41 //2、查询用户的品牌向量
42 int uid = MapUtils.getIntValue(paramMap, "uid", 0); 42 int uid = MapUtils.getIntValue(paramMap, "uid", 0);
43 String udid = MapUtils.getString(paramMap, "udid", ""); 43 String udid = MapUtils.getString(paramMap, "udid", "");
44 - UserPersonalFactorRspNew userPersonalFactorRspNew = userComponent.queryUserPersionalFactor(uid, udid, null); 44 + UserPersonalFactorRsp userPersonalFactorRsp = userComponent.queryUserPersionalFactor(uid, udid, null);
45 //3、按相关性聚合品牌 45 //3、按相关性聚合品牌
46 - List<Integer> shopIds = persionalShopService.buildPersionalShopIds(shopBrandList, userPersonalFactorRspNew); 46 + List<Integer> shopIds = persionalShopService.buildPersionalShopIds(shopBrandList, userPersonalFactorRsp);
47 //4、查询店铺 47 //4、查询店铺
48 List<Map<String, Object>> shopsList = shopsIndexBaseService.getShopListByIdsWithSortAndStatus(shopIds); 48 List<Map<String, Object>> shopsList = shopsIndexBaseService.getShopListByIdsWithSortAndStatus(shopIds);
49 //5、数量截取 49 //5、数量截取
@@ -5,7 +5,7 @@ import com.yoho.search.base.utils.SearchCollectionUtils; @@ -5,7 +5,7 @@ import com.yoho.search.base.utils.SearchCollectionUtils;
5 import com.yoho.search.cache.beans.AbstractCacheBean; 5 import com.yoho.search.cache.beans.AbstractCacheBean;
6 import com.yoho.search.core.personalized.models.PersonalizedSearch; 6 import com.yoho.search.core.personalized.models.PersonalizedSearch;
7 import com.yoho.search.core.personalized.models.SortBrand; 7 import com.yoho.search.core.personalized.models.SortBrand;
8 -import com.yoho.search.core.personalized.models.UserPersonalFactorRspNew; 8 +import com.yoho.search.core.personalized.models.UserPersonalFactorRsp;
9 import com.yoho.search.service.recall.beans.persional.ProductFeatureFactorComponent; 9 import com.yoho.search.service.recall.beans.persional.ProductFeatureFactorComponent;
10 import com.yoho.search.service.recall.beans.persional.UserPersionalFactorComponent; 10 import com.yoho.search.service.recall.beans.persional.UserPersionalFactorComponent;
11 import com.yoho.search.service.recall.beans.strategy.IStrategy; 11 import com.yoho.search.service.recall.beans.strategy.IStrategy;
@@ -75,7 +75,7 @@ public class AggBrandProductCacheBean extends AbstractCacheBean<BrandProductRequ @@ -75,7 +75,7 @@ public class AggBrandProductCacheBean extends AbstractCacheBean<BrandProductRequ
75 List<Integer> aggBrandIds = aggBrands.stream().map(AggBrand::getBrandId).filter(Objects::nonNull).collect(Collectors.toList()); 75 List<Integer> aggBrandIds = aggBrands.stream().map(AggBrand::getBrandId).filter(Objects::nonNull).collect(Collectors.toList());
76 List<Integer> userPersonalbrandIds = new ArrayList<>(); 76 List<Integer> userPersonalbrandIds = new ArrayList<>();
77 if (brandProductRequest.hasUidOrUdid()) { 77 if (brandProductRequest.hasUidOrUdid()) {
78 - UserPersonalFactorRspNew userFactor = userComponent.queryUserPersionalFactor(brandProductRequest.getUid(), brandProductRequest.getUdid(), null); 78 + UserPersonalFactorRsp userFactor = userComponent.queryUserPersionalFactor(brandProductRequest.getUid(), brandProductRequest.getUdid(), null);
79 userPersonalbrandIds = buildUserPersonalBrandIds(aggBrandIds, userFactor, brandProductRequest.getBrandCount()); 79 userPersonalbrandIds = buildUserPersonalBrandIds(aggBrandIds, userFactor, brandProductRequest.getBrandCount());
80 } 80 }
81 if (userPersonalbrandIds.size() < brandProductRequest.getBrandCount()) { 81 if (userPersonalbrandIds.size() < brandProductRequest.getBrandCount()) {
@@ -143,7 +143,7 @@ public class AggBrandProductCacheBean extends AbstractCacheBean<BrandProductRequ @@ -143,7 +143,7 @@ public class AggBrandProductCacheBean extends AbstractCacheBean<BrandProductRequ
143 } 143 }
144 144
145 145
146 - private List<Integer> buildUserPersonalBrandIds(List<Integer> aggBrandIds, UserPersonalFactorRspNew userFactor, int count) { 146 + private List<Integer> buildUserPersonalBrandIds(List<Integer> aggBrandIds, UserPersonalFactorRsp userFactor, int count) {
147 List<Integer> result = new ArrayList<>(); 147 List<Integer> result = new ArrayList<>();
148 double userBrandVectorNorm = Word2VectorCalculator.getVectorListNorm(userFactor.getBrandVectorW2v()); 148 double userBrandVectorNorm = Word2VectorCalculator.getVectorListNorm(userFactor.getBrandVectorW2v());
149 List<BrandVectorScore> brandVectorScores = new ArrayList<>(); 149 List<BrandVectorScore> brandVectorScores = new ArrayList<>();