Authored by 胡古飞

搜索新增一种召回

@@ -12,6 +12,7 @@ public class UserPersonalFactor { @@ -12,6 +12,7 @@ public class UserPersonalFactor {
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; 14 private List<Integer> realTimeYoutubeSknList;
  15 + private List<Integer> realTimeYtbNewSknList;
15 16
16 private List<SortPriceAreas> sortPriceAreasList; 17 private List<SortPriceAreas> sortPriceAreasList;
17 18
@@ -25,6 +26,7 @@ public class UserPersonalFactor { @@ -25,6 +26,7 @@ public class UserPersonalFactor {
25 this.recommendSknList = new ArrayList<>(); 26 this.recommendSknList = new ArrayList<>();
26 this.realTimeSimilarSknList = new ArrayList<>(); 27 this.realTimeSimilarSknList = new ArrayList<>();
27 this.realTimeYoutubeSknList = new ArrayList<>(); 28 this.realTimeYoutubeSknList = new ArrayList<>();
  29 + this.realTimeYtbNewSknList = new ArrayList<>();
28 30
29 this.sortPriceAreasList = new ArrayList<>(); 31 this.sortPriceAreasList = new ArrayList<>();
30 32
@@ -35,10 +37,19 @@ public class UserPersonalFactor { @@ -35,10 +37,19 @@ public class UserPersonalFactor {
35 this.orderAvaiable = false; 37 this.orderAvaiable = false;
36 } 38 }
37 39
38 - public UserPersonalFactor(List<Integer> recommendSknList, List<Integer> realTimeSimilarSknList,List<Integer> realTimeYoutubeSknList, List<SortPriceAreas> sortPriceAreasList, List<SortBrand> realTimeSortBrandList, List<SortBrand> vectorRnnSortBrandList, List<SortBrand> vectorW2vSortBrandList,boolean orderAvaiable) { 40 + public UserPersonalFactor(List<Integer> recommendSknList,
  41 + List<Integer> realTimeSimilarSknList,
  42 + List<Integer> realTimeYoutubeSknList,
  43 + List<Integer> realTimeYtbNewSknList,
  44 + List<SortPriceAreas> sortPriceAreasList,
  45 + List<SortBrand> realTimeSortBrandList,
  46 + List<SortBrand> vectorRnnSortBrandList,
  47 + List<SortBrand> vectorW2vSortBrandList,
  48 + boolean orderAvaiable) {
39 this.recommendSknList = recommendSknList; 49 this.recommendSknList = recommendSknList;
40 this.realTimeSimilarSknList = realTimeSimilarSknList; 50 this.realTimeSimilarSknList = realTimeSimilarSknList;
41 this.realTimeYoutubeSknList = realTimeYoutubeSknList; 51 this.realTimeYoutubeSknList = realTimeYoutubeSknList;
  52 + this.realTimeYtbNewSknList = realTimeYtbNewSknList;
42 this.sortPriceAreasList = sortPriceAreasList; 53 this.sortPriceAreasList = sortPriceAreasList;
43 this.realTimeSortBrandList = realTimeSortBrandList; 54 this.realTimeSortBrandList = realTimeSortBrandList;
44 this.vectorRnnSortBrandList = vectorRnnSortBrandList; 55 this.vectorRnnSortBrandList = vectorRnnSortBrandList;
@@ -74,31 +85,39 @@ public class UserPersonalFactor { @@ -74,31 +85,39 @@ public class UserPersonalFactor {
74 return realTimeYoutubeSknList; 85 return realTimeYoutubeSknList;
75 } 86 }
76 87
  88 + public List<Integer> getRealTimeYtbNewSknList() {
  89 + return realTimeYtbNewSknList;
  90 + }
  91 +
77 public boolean isOrderAvaiable() { 92 public boolean isOrderAvaiable() {
78 return orderAvaiable; 93 return orderAvaiable;
79 } 94 }
80 95
81 /** 96 /**
82 * 判断用户个性化数据是否都为空 97 * 判断用户个性化数据是否都为空
  98 + *
83 * @return 99 * @return
84 */ 100 */
85 - public boolean isUserPersonalFactorEmpty(){  
86 - if(!CollectionUtils.isEmpty(this.recommendSknList)){ 101 + public boolean isUserPersonalFactorEmpty() {
  102 + if (!CollectionUtils.isEmpty(this.recommendSknList)) {
  103 + return false;
  104 + }
  105 + if (!CollectionUtils.isEmpty(this.realTimeSimilarSknList)) {
87 return false; 106 return false;
88 } 107 }
89 - if(!CollectionUtils.isEmpty(this.realTimeSimilarSknList)){ 108 + if (!CollectionUtils.isEmpty(this.realTimeYoutubeSknList)) {
90 return false; 109 return false;
91 } 110 }
92 - if(!CollectionUtils.isEmpty(this.realTimeYoutubeSknList)){ 111 + if (!CollectionUtils.isEmpty(this.realTimeYtbNewSknList)) {
93 return false; 112 return false;
94 } 113 }
95 - if(!CollectionUtils.isEmpty(this.realTimeSortBrandList)){ 114 + if (!CollectionUtils.isEmpty(this.realTimeSortBrandList)) {
96 return false; 115 return false;
97 } 116 }
98 - if(!CollectionUtils.isEmpty(this.vectorRnnSortBrandList)){ 117 + if (!CollectionUtils.isEmpty(this.vectorRnnSortBrandList)) {
99 return false; 118 return false;
100 } 119 }
101 - if(!CollectionUtils.isEmpty(this.vectorW2vSortBrandList)){ 120 + if (!CollectionUtils.isEmpty(this.vectorW2vSortBrandList)) {
102 return false; 121 return false;
103 } 122 }
104 return true; 123 return true;
  1 +package com.yoho.search.restapi.tools;
  2 +
  3 +import com.yoho.search.core.personalized.service.BidataServiceCaller;
  4 +import com.yoho.search.core.personalized.service.PersonalVersionManager;
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.web.bind.annotation.RequestMapping;
  7 +import org.springframework.web.bind.annotation.RestController;
  8 +
  9 +import java.util.HashMap;
  10 +import java.util.Map;
  11 +
  12 +@RestController
  13 +@RequestMapping(value = "/tools")
  14 +public class BigdataTestController {
  15 +
  16 + @Autowired
  17 + private PersonalVersionManager personalVersionManager;
  18 + @Autowired
  19 + private BidataServiceCaller bidataServiceCaller;
  20 +
  21 + @RequestMapping(value = "/bigdataServiceTest")
  22 + public Map<String, Object> bigdataServiceTets(Integer uid) {
  23 + Map<String, Object> results = new HashMap<>();
  24 +
  25 + //大数据目前推荐的版本
  26 + String bigDataRecomDateStr = personalVersionManager.getBigDataRecomDateStr();
  27 + results.put("bigDataRecomDateStr", bigDataRecomDateStr == null ? "" : bigDataRecomDateStr);
  28 + results.put("bigDataRecomDateStrFeatures", bidataServiceCaller.getUserVectorFeature(uid.toString(), bigDataRecomDateStr));
  29 +
  30 + //zk中目前的版本
  31 + String currentVersionInZk = personalVersionManager.getCurrentVersionInZk();
  32 + results.put("currentVersionInZk", currentVersionInZk == null ? "" : currentVersionInZk);
  33 + results.put("currentVersionInZkFeatures", bidataServiceCaller.getUserVectorFeature(uid.toString(), currentVersionInZk));
  34 +
  35 + //用户性别偏好
  36 + results.put("userGenderFeature", bidataServiceCaller.getUserGenderFeature(uid.toString()));
  37 + //用户尺码偏好
  38 + results.put("userFavoriteSizes", bidataServiceCaller.getUserFavoriteSizes(uid.toString()));
  39 + //用户个性化因子
  40 + results.put("userPersionalFactor", bidataServiceCaller.queryUserPersionalFactor(uid, null, null));
  41 + return results;
  42 + }
  43 +
  44 +}
@@ -41,11 +41,11 @@ public class QueryUserPersionalFactorBean { @@ -41,11 +41,11 @@ public class QueryUserPersionalFactorBean {
41 long begin = System.currentTimeMillis(); 41 long begin = System.currentTimeMillis();
42 //2、获取用户的个性化因子 42 //2、获取用户的个性化因子
43 UserPersonalFactorRsp userFactor = userComponent.queryUserPersionalFactor(userRecallRequest.getUid(), userRecallRequest.getUdid(), pageFactor.getMisortIds()); 43 UserPersonalFactorRsp userFactor = userComponent.queryUserPersionalFactor(userRecallRequest.getUid(), userRecallRequest.getUdid(), pageFactor.getMisortIds());
44 - RecallLoggerHelper.info("QueryUserPersionalFactorBean[1]:queryUserPersionalFactor. uid is[{}],udid is[{}], cost is[{}ms]", userRecallRequest.getUid(), userRecallRequest.getUdid(), System.currentTimeMillis()-begin); 44 + RecallLoggerHelper.info("QueryUserPersionalFactorBean[1]:queryUserPersionalFactor. uid is[{}],udid is[{}], cost is[{}ms]", userRecallRequest.getUid(), userRecallRequest.getUdid(), System.currentTimeMillis() - begin);
45 //3、构造结果 45 //3、构造结果
46 begin = System.currentTimeMillis(); 46 begin = System.currentTimeMillis();
47 UserPersonalFactor userPersonalFactor = this.buildUserPersonalFactor(userRecallRequest, pageFactor, userFactor); 47 UserPersonalFactor userPersonalFactor = this.buildUserPersonalFactor(userRecallRequest, pageFactor, userFactor);
48 - RecallLoggerHelper.info("QueryUserPersionalFactorBean[2]:buildUserPersonalFactor. uid is[{}],udid is[{}], cost is[{}ms]", userRecallRequest.getUid(), userRecallRequest.getUdid(), System.currentTimeMillis()-begin); 48 + RecallLoggerHelper.info("QueryUserPersionalFactorBean[2]:buildUserPersonalFactor. uid is[{}],udid is[{}], cost is[{}ms]", userRecallRequest.getUid(), userRecallRequest.getUdid(), System.currentTimeMillis() - begin);
49 return userPersonalFactor; 49 return userPersonalFactor;
50 } catch (Exception e) { 50 } catch (Exception e) {
51 RecallLoggerHelper.error(e.getMessage(), e); 51 RecallLoggerHelper.error(e.getMessage(), e);
@@ -57,53 +57,56 @@ public class QueryUserPersionalFactorBean { @@ -57,53 +57,56 @@ public class QueryUserPersionalFactorBean {
57 //1、构造品类价格带 57 //1、构造品类价格带
58 List<SortPriceAreas> sortPriceAreasList = this.getSortPriceAreasListWithSort(userFactor, pageFactor); 58 List<SortPriceAreas> sortPriceAreasList = this.getSortPriceAreasListWithSort(userFactor, pageFactor);
59 59
60 - //2、构造推荐的skn列表  
61 - List<Integer> recommendSknList = userFactor.getRecommendSknList();  
62 - List<Integer> realTimeSimilarSknList = userFactor.getRealTimeSimilarSknList();  
63 - List<Integer> realTimeYoutubeSknList = userFactor.getRealTimeYoutubeSknList();  
64 -  
65 - //3、获取页面中存在的所有的key 60 + //2、获取页面中存在的所有的品类品牌key
66 Set<String> pageSortBrandKeys = new HashSet<>(); 61 Set<String> pageSortBrandKeys = new HashSet<>();
67 for (SortBrand pageSortBrand : pageFactor.getSortBrandList()) { 62 for (SortBrand pageSortBrand : pageFactor.getSortBrandList()) {
68 pageSortBrandKeys.add(pageSortBrand.key()); 63 pageSortBrandKeys.add(pageSortBrand.key());
69 } 64 }
70 65
71 - //4、构造实时【品类+品牌】 66 + //3、构造实时【品类+品牌】
72 int recSortBrandCount = recallConfigService.querySortBrandConfigCount(userRecallRequest, SortBrandType.REC_SORT_BRAND, 12); 67 int recSortBrandCount = recallConfigService.querySortBrandConfigCount(userRecallRequest, SortBrandType.REC_SORT_BRAND, 12);
73 List<SortBrand> realTimeSortBrandList = this.joinRealTimeSortBrandList(pageSortBrandKeys, userFactor.getRealTimeSortBrandList(), recSortBrandCount); 68 List<SortBrand> realTimeSortBrandList = this.joinRealTimeSortBrandList(pageSortBrandKeys, userFactor.getRealTimeSortBrandList(), recSortBrandCount);
74 69
75 - //5、构造临时过滤对象 70 + //4、构造临时过滤对象
76 Set<String> filterSortBrandKeys = new HashSet<>(); 71 Set<String> filterSortBrandKeys = new HashSet<>();
77 for (SortBrand existSortBrand : realTimeSortBrandList) { 72 for (SortBrand existSortBrand : realTimeSortBrandList) {
78 filterSortBrandKeys.add(existSortBrand.key()); 73 filterSortBrandKeys.add(existSortBrand.key());
79 } 74 }
80 - //6、构造基于RNN向量的【品牌+品牌】,去除实时的品类和品牌 75 +
  76 + //5、构造基于RNN向量的【品牌+品牌】,去除实时的品类和品牌
81 int vectorRNNSortBrandCount = recallConfigService.querySortBrandConfigCount(userRecallRequest, SortBrandType.VEC_RNN_SORT_BRAND, 0); 77 int vectorRNNSortBrandCount = recallConfigService.querySortBrandConfigCount(userRecallRequest, SortBrandType.VEC_RNN_SORT_BRAND, 0);
82 List<SortBrand> vectorRnnSortBrandList = sortBrandVectorComponent.queryVectorSortBrandList(pageFactor, filterSortBrandKeys, userFactor.getBrandVector(), userFactor.getSortBrandVector(), true, vectorRNNSortBrandCount); 78 List<SortBrand> vectorRnnSortBrandList = sortBrandVectorComponent.queryVectorSortBrandList(pageFactor, filterSortBrandKeys, userFactor.getBrandVector(), userFactor.getSortBrandVector(), true, vectorRNNSortBrandCount);
83 for (SortBrand existSortBrand : vectorRnnSortBrandList) { 79 for (SortBrand existSortBrand : vectorRnnSortBrandList) {
84 filterSortBrandKeys.add(existSortBrand.key()); 80 filterSortBrandKeys.add(existSortBrand.key());
85 } 81 }
86 - //7、构造基于W2V向量的【品牌+品牌】,去除实时的品类和品牌 82 +
  83 + //6、构造基于W2V向量的【品牌+品牌】,去除实时的品类和品牌
87 int vecW2vSortBrandCount = recallConfigService.querySortBrandConfigCount(userRecallRequest, SortBrandType.VEC_W2V_SORT_BRAND, 12); 84 int vecW2vSortBrandCount = recallConfigService.querySortBrandConfigCount(userRecallRequest, SortBrandType.VEC_W2V_SORT_BRAND, 12);
88 List<SortBrand> vectorW2vSortBrandList = sortBrandVectorComponent.queryVectorSortBrandList(pageFactor, filterSortBrandKeys, userFactor.getBrandVectorW2v(), userFactor.getSortBrandVectorW2v(), false, vecW2vSortBrandCount); 85 List<SortBrand> vectorW2vSortBrandList = sortBrandVectorComponent.queryVectorSortBrandList(pageFactor, filterSortBrandKeys, userFactor.getBrandVectorW2v(), userFactor.getSortBrandVectorW2v(), false, vecW2vSortBrandCount);
89 for (SortBrand existSortBrand : vectorW2vSortBrandList) { 86 for (SortBrand existSortBrand : vectorW2vSortBrandList) {
90 filterSortBrandKeys.add(existSortBrand.key()); 87 filterSortBrandKeys.add(existSortBrand.key());
91 } 88 }
92 89
93 - //8、是否下过单  
94 - boolean orderAvaiable = userFactor.isOrderAvailable();  
95 -  
96 - //9、构造个性化结果  
97 - UserPersonalFactor userPersonalFactor = new UserPersonalFactor(recommendSknList, realTimeSimilarSknList, realTimeYoutubeSknList, sortPriceAreasList, realTimeSortBrandList, vectorRnnSortBrandList, vectorW2vSortBrandList,orderAvaiable);  
98 -  
99 - //10、如果个性化结果为空,再取配置的品类品牌数据 90 + //7、构造个性化结果
  91 + UserPersonalFactor userPersonalFactor = new UserPersonalFactor(
  92 + userFactor.getRecommendSknList(),
  93 + userFactor.getRealTimeSimilarSknList(),
  94 + userFactor.getRealTimeYoutubeSknList(),
  95 + userFactor.getRealTimeYtbNewSknList(),
  96 + sortPriceAreasList,
  97 + realTimeSortBrandList,
  98 + vectorRnnSortBrandList,
  99 + vectorW2vSortBrandList,
  100 + userFactor.isOrderAvailable());
  101 +
  102 + //8、如果个性化结果为空,再取配置的品类品牌数据
100 if (userPersonalFactor.isUserPersonalFactorEmpty()) { 103 if (userPersonalFactor.isUserPersonalFactorEmpty()) {
101 int configSortBrandCount = recallConfigService.querySortBrandConfigCount(userRecallRequest, SortBrandType.CONFIG_SORT_BRAND, 12); 104 int configSortBrandCount = recallConfigService.querySortBrandConfigCount(userRecallRequest, SortBrandType.CONFIG_SORT_BRAND, 12);
102 List<SortBrand> configSortBrandList = recallConfigService.randomConfigSortBrand(pageFactor, pageSortBrandKeys, filterSortBrandKeys, configSortBrandCount); 105 List<SortBrand> configSortBrandList = recallConfigService.randomConfigSortBrand(pageFactor, pageSortBrandKeys, filterSortBrandKeys, configSortBrandCount);
103 userPersonalFactor.setConfigSortBrandList(configSortBrandList); 106 userPersonalFactor.setConfigSortBrandList(configSortBrandList);
104 } 107 }
105 108
106 - //11、返回最终结果 109 + //9、返回最终结果
107 return userPersonalFactor; 110 return userPersonalFactor;
108 } 111 }
109 112
@@ -45,6 +45,10 @@ public class UserPersionalFactorComponent { @@ -45,6 +45,10 @@ public class UserPersionalFactorComponent {
45 if (rsp.getRealTimeYoutubeSknList() == null) { 45 if (rsp.getRealTimeYoutubeSknList() == null) {
46 rsp.setRealTimeYoutubeSknList(new ArrayList<>()); 46 rsp.setRealTimeYoutubeSknList(new ArrayList<>());
47 } 47 }
  48 + //realTimeYtbNewSknList
  49 + if (rsp.getRealTimeYtbNewSknList() == null) {
  50 + rsp.setRealTimeYtbNewSknList(new ArrayList<>());
  51 + }
48 //价格带 52 //价格带
49 if (rsp.getSortPriceAreasList() == null) { 53 if (rsp.getSortPriceAreasList() == null) {
50 rsp.setSortPriceAreasList(new ArrayList<>()); 54 rsp.setSortPriceAreasList(new ArrayList<>());
@@ -19,10 +19,7 @@ import com.yoho.search.service.recall.helper.ExtendFilterHelper; @@ -19,10 +19,7 @@ import com.yoho.search.service.recall.helper.ExtendFilterHelper;
19 import com.yoho.search.service.recall.helper.RecallLoggerHelper; 19 import com.yoho.search.service.recall.helper.RecallLoggerHelper;
20 import com.yoho.search.service.recall.helper.StrategyHelper; 20 import com.yoho.search.service.recall.helper.StrategyHelper;
21 import com.yoho.search.service.recall.strategy.StrategyEnum; 21 import com.yoho.search.service.recall.strategy.StrategyEnum;
22 -import com.yoho.search.service.recall.strategy.impls.IRecallSknStrategy;  
23 -import com.yoho.search.service.recall.strategy.impls.RealTimeSimilarSknStrategy;  
24 -import com.yoho.search.service.recall.strategy.impls.RealTimeYoutuboSknStrategy;  
25 -import com.yoho.search.service.recall.strategy.impls.RecommendSknStrategy; 22 +import com.yoho.search.service.recall.strategy.impls.*;
26 import org.apache.commons.collections.CollectionUtils; 23 import org.apache.commons.collections.CollectionUtils;
27 import org.apache.commons.collections.MapUtils; 24 import org.apache.commons.collections.MapUtils;
28 import org.apache.commons.lang.StringUtils; 25 import org.apache.commons.lang.StringUtils;
@@ -59,7 +56,7 @@ public class SknRecallRecallRequestResponseBuilder { @@ -59,7 +56,7 @@ public class SknRecallRecallRequestResponseBuilder {
59 public List<RecallRequestResponse> buildRecallRequestsForSkn(UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) { 56 public List<RecallRequestResponse> buildRecallRequestsForSkn(UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) {
60 try { 57 try {
61 List<Integer> filterSknList = new ArrayList<>(); 58 List<Integer> filterSknList = new ArrayList<>();
62 - //1、获取实时点击skn的配置 59 +// 1、获取实时点击skn的配置
63 int recSknCount = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.REC_SKN, 0); 60 int recSknCount = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.REC_SKN, 0);
64 if (recSknCount > 0 && userPersonalFactor.getRecommendSknList() != null) { 61 if (recSknCount > 0 && userPersonalFactor.getRecommendSknList() != null) {
65 filterSknList.addAll(userPersonalFactor.getRecommendSknList()); 62 filterSknList.addAll(userPersonalFactor.getRecommendSknList());
@@ -68,7 +65,7 @@ public class SknRecallRecallRequestResponseBuilder { @@ -68,7 +65,7 @@ public class SknRecallRecallRequestResponseBuilder {
68 } 65 }
69 RecallLoggerHelper.infoDetail(userRecallRequest, "buildRecallRequestsForSkn, REC_SKN size is [{}]", recSknCount); 66 RecallLoggerHelper.infoDetail(userRecallRequest, "buildRecallRequestsForSkn, REC_SKN size is [{}]", recSknCount);
70 67
71 - //2、获取相似skn的配置 68 + //2、获取相似skn-youtube的配置
72 int youtubeSknCount = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.RT_YOUTUBE_SKN, 0); 69 int youtubeSknCount = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.RT_YOUTUBE_SKN, 0);
73 if (youtubeSknCount > 0 && userPersonalFactor.getRealTimeYoutubeSknList() != null) { 70 if (youtubeSknCount > 0 && userPersonalFactor.getRealTimeYoutubeSknList() != null) {
74 filterSknList.addAll(userPersonalFactor.getRealTimeYoutubeSknList()); 71 filterSknList.addAll(userPersonalFactor.getRealTimeYoutubeSknList());
@@ -77,16 +74,25 @@ public class SknRecallRecallRequestResponseBuilder { @@ -77,16 +74,25 @@ public class SknRecallRecallRequestResponseBuilder {
77 } 74 }
78 RecallLoggerHelper.infoDetail(userRecallRequest, "buildRecallRequestsForSkn, RT_YOUTUBE_SKN size is [{}]", youtubeSknCount); 75 RecallLoggerHelper.infoDetail(userRecallRequest, "buildRecallRequestsForSkn, RT_YOUTUBE_SKN size is [{}]", youtubeSknCount);
79 76
80 - //3、获取相似skn的配置 77 + //3、获取相似skn-youtube-new的配置
  78 + int ytbNewSknCount = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.RT_YTB_NEW_SKN, 0);
  79 + if (ytbNewSknCount > 0 && userPersonalFactor.getRealTimeYtbNewSknList() != null) {
  80 + filterSknList.addAll(userPersonalFactor.getRealTimeYtbNewSknList());
  81 + } else {
  82 + ytbNewSknCount = 0;
  83 + }
  84 + RecallLoggerHelper.infoDetail(userRecallRequest, "buildRecallRequestsForSkn, RT_YTB_NEW_SKN size is [{}]", ytbNewSknCount);
  85 +
  86 + //4、获取相似skn的配置
81 int rtSimSknCount = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.RT_SIM_SKN, 0); 87 int rtSimSknCount = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.RT_SIM_SKN, 0);
82 if (rtSimSknCount > 0 && userPersonalFactor.getRealTimeSimilarSknList() != null) { 88 if (rtSimSknCount > 0 && userPersonalFactor.getRealTimeSimilarSknList() != null) {
83 filterSknList.addAll(userPersonalFactor.getRealTimeSimilarSknList()); 89 filterSknList.addAll(userPersonalFactor.getRealTimeSimilarSknList());
84 } else { 90 } else {
85 rtSimSknCount = 0; 91 rtSimSknCount = 0;
86 } 92 }
87 - RecallLoggerHelper.infoDetail(userRecallRequest, "buildRecallRequestsForSkn, rtSimSknCount size is [{}]", rtSimSknCount); 93 + RecallLoggerHelper.infoDetail(userRecallRequest, "buildRecallRequestsForSkn, RT_SIM_SKN size is [{}]", rtSimSknCount);
88 94
89 - //4、执行查询 95 + //5、执行查询
90 if (filterSknList.isEmpty()) { 96 if (filterSknList.isEmpty()) {
91 return new ArrayList<>(); 97 return new ArrayList<>();
92 } 98 }
@@ -96,7 +102,8 @@ public class SknRecallRecallRequestResponseBuilder { @@ -96,7 +102,8 @@ public class SknRecallRecallRequestResponseBuilder {
96 } else { 102 } else {
97 sknResults = this.filterRecommedSknListByEs(userRecallRequest, filterSknList); 103 sknResults = this.filterRecommedSknListByEs(userRecallRequest, filterSknList);
98 } 104 }
99 - //5、构造结果 105 +
  106 + //6、构造结果
100 List<RecallRequestResponse> results = new ArrayList<>(); 107 List<RecallRequestResponse> results = new ArrayList<>();
101 ParamQueryFilter paramQueryFilter = userRecallRequest.getParamQueryFilter(); 108 ParamQueryFilter paramQueryFilter = userRecallRequest.getParamQueryFilter();
102 if (recSknCount > 0) { 109 if (recSknCount > 0) {
@@ -105,6 +112,9 @@ public class SknRecallRecallRequestResponseBuilder { @@ -105,6 +112,9 @@ public class SknRecallRecallRequestResponseBuilder {
105 if (youtubeSknCount > 0) { 112 if (youtubeSknCount > 0) {
106 results.addAll(this.buildResults(paramQueryFilter, userPersonalFactor.getRealTimeYoutubeSknList(), RealTimeYoutuboSknStrategy.class, sknResults, youtubeSknCount)); 113 results.addAll(this.buildResults(paramQueryFilter, userPersonalFactor.getRealTimeYoutubeSknList(), RealTimeYoutuboSknStrategy.class, sknResults, youtubeSknCount));
107 } 114 }
  115 + if (ytbNewSknCount > 0) {
  116 + results.addAll(this.buildResults(paramQueryFilter, userPersonalFactor.getRealTimeYtbNewSknList(), RealTimeYtbNewSknStrategy.class, sknResults, ytbNewSknCount));
  117 + }
108 if (rtSimSknCount > 0) { 118 if (rtSimSknCount > 0) {
109 results.addAll(this.buildResults(paramQueryFilter, userPersonalFactor.getRealTimeSimilarSknList(), RealTimeSimilarSknStrategy.class, sknResults, rtSimSknCount)); 119 results.addAll(this.buildResults(paramQueryFilter, userPersonalFactor.getRealTimeSimilarSknList(), RealTimeSimilarSknStrategy.class, sknResults, rtSimSknCount));
110 } 120 }
1 package com.yoho.search.service.recall.helper; 1 package com.yoho.search.service.recall.helper;
2 2
3 import com.yoho.search.service.recall.strategy.StrategyEnum; 3 import com.yoho.search.service.recall.strategy.StrategyEnum;
4 -import com.yoho.search.service.recall.strategy.impls.IRecallSknStrategy;  
5 -import com.yoho.search.service.recall.strategy.impls.RealTimeSimilarSknStrategy;  
6 -import com.yoho.search.service.recall.strategy.impls.RealTimeYoutuboSknStrategy;  
7 -import com.yoho.search.service.recall.strategy.impls.RecommendSknStrategy; 4 +import com.yoho.search.service.recall.strategy.impls.*;
  5 +import org.slf4j.Logger;
  6 +import org.slf4j.LoggerFactory;
  7 +
  8 +import java.lang.reflect.Constructor;
8 9
9 public class StrategyHelper { 10 public class StrategyHelper {
10 11
  12 + private static final Logger logger = LoggerFactory.getLogger(StrategyHelper.class);
  13 +
11 /** 14 /**
12 * 兜底找回类型枚举 15 * 兜底找回类型枚举
13 * 16 *
@@ -23,7 +26,16 @@ public class StrategyHelper { @@ -23,7 +26,16 @@ public class StrategyHelper {
23 * @return 26 * @return
24 */ 27 */
25 public static boolean isRecommendSknStrage(StrategyEnum strategy) { 28 public static boolean isRecommendSknStrage(StrategyEnum strategy) {
26 - if (strategy.equals(StrategyEnum.REC_SKN) || strategy.equals(StrategyEnum.RT_SIM_SKN) || strategy.equals(StrategyEnum.RT_YOUTUBE_SKN)) { 29 + if (strategy.equals(StrategyEnum.REC_SKN)) {
  30 + return true;
  31 + }
  32 + if (strategy.equals(StrategyEnum.RT_SIM_SKN)) {
  33 + return true;
  34 + }
  35 + if (strategy.equals(StrategyEnum.RT_YOUTUBE_SKN)) {
  36 + return true;
  37 + }
  38 + if (strategy.equals(StrategyEnum.RT_YTB_NEW_SKN)) {
27 return true; 39 return true;
28 } 40 }
29 return false; 41 return false;
@@ -35,13 +47,24 @@ public class StrategyHelper { @@ -35,13 +47,24 @@ public class StrategyHelper {
35 * @return 47 * @return
36 */ 48 */
37 public static IRecallSknStrategy getRecallSknStrategy(Class<? extends IRecallSknStrategy> clazz, Integer skn) { 49 public static IRecallSknStrategy getRecallSknStrategy(Class<? extends IRecallSknStrategy> clazz, Integer skn) {
38 - if (clazz.isAssignableFrom(RecommendSknStrategy.class)) {  
39 - return new RecommendSknStrategy(skn);  
40 - }  
41 - if (clazz.isAssignableFrom(RealTimeYoutuboSknStrategy.class)) {  
42 - return new RealTimeYoutuboSknStrategy(skn); 50 + try {
  51 + Constructor<? extends IRecallSknStrategy> c = clazz.getConstructor(Integer.class);
  52 + return c.newInstance(skn);
  53 + }catch (Exception e){
  54 + logger.error(e.getMessage(),e);
  55 + return null;
43 } 56 }
44 - return new RealTimeSimilarSknStrategy(skn); 57 +//
  58 +// if (clazz.isAssignableFrom(RecommendSknStrategy.class)) {
  59 +// return new RecommendSknStrategy(skn);
  60 +// }
  61 +// if (clazz.isAssignableFrom(RealTimeYoutuboSknStrategy.class)) {
  62 +// return new RealTimeYoutuboSknStrategy(skn);
  63 +// }
  64 +// if (clazz.isAssignableFrom(RealTimeYtbNewSknStrategy.class)) {
  65 +// return new RealTimeYtbNewSknStrategy(skn);
  66 +// }
  67 +// return new RealTimeSimilarSknStrategy(skn);
45 } 68 }
46 69
47 70
@@ -11,8 +11,9 @@ public enum StrategyEnum { @@ -11,8 +11,9 @@ public enum StrategyEnum {
11 DIRECT_TRAIN_SORT_PRICE(896),//直通车-品类价格带 11 DIRECT_TRAIN_SORT_PRICE(896),//直通车-品类价格带
12 12
13 REC_SKN(800),//实时推荐的skn 13 REC_SKN(800),//实时推荐的skn
14 - RT_SIM_SKN(798),//实时推荐的skn的相似skn  
15 - RT_YOUTUBE_SKN(799),//实时推荐的skn的相似skn-基于YOUTUBE 14 + RT_SIM_SKN(797),//实时推荐的skn的相似skn
  15 + RT_YOUTUBE_SKN(798),//实时推荐的skn的相似skn-基于YOUTUBE
  16 + RT_YTB_NEW_SKN(799),//实时推荐的skn的相似skn-基于YOUTUBE-NEW
16 17
17 ADD_FLOW(700),//流量补偿 18 ADD_FLOW(700),//流量补偿
18 NEW_SHOP(699),//新开店铺 19 NEW_SHOP(699),//新开店铺
  1 +package com.yoho.search.service.recall.strategy.impls;
  2 +
  3 +import com.yoho.search.service.recall.strategy.StrategyEnum;
  4 +
  5 +public class RealTimeYtbNewSknStrategy extends IRecallSknStrategy {
  6 +
  7 + public RealTimeYtbNewSknStrategy(Integer recommendSkn) {
  8 + super(recommendSkn);
  9 + }
  10 +
  11 + @Override
  12 + public StrategyEnum strategtEnum() {
  13 + return StrategyEnum.RT_YTB_NEW_SKN;
  14 + }
  15 +
  16 +}