Showing
1 changed file
with
7 additions
and
40 deletions
@@ -15,8 +15,6 @@ import com.yoho.search.recall.scene.models.personal.UserPersonalFactor; | @@ -15,8 +15,6 @@ import com.yoho.search.recall.scene.models.personal.UserPersonalFactor; | ||
15 | import com.yoho.search.recall.scene.models.req.SknBaseInfoResponse; | 15 | import com.yoho.search.recall.scene.models.req.SknBaseInfoResponse; |
16 | import com.yoho.search.recall.scene.models.req.UserRecallRequest; | 16 | import com.yoho.search.recall.scene.models.req.UserRecallRequest; |
17 | import com.yoho.search.recall.scene.models.req.UserRecallResponse; | 17 | import com.yoho.search.recall.scene.models.req.UserRecallResponse; |
18 | -import com.yoho.search.service.base.ProductListSortKey; | ||
19 | -import com.yoho.search.service.base.ProductListSortService; | ||
20 | import com.yoho.search.service.base.SearchDynamicConfigService; | 18 | import com.yoho.search.service.base.SearchDynamicConfigService; |
21 | import com.yoho.search.service.scorer.personal.PersonalVectorFeatureSearch; | 19 | import com.yoho.search.service.scorer.personal.PersonalVectorFeatureSearch; |
22 | import org.slf4j.Logger; | 20 | import org.slf4j.Logger; |
@@ -40,8 +38,6 @@ public class UserRecallResponseBuilder { | @@ -40,8 +38,6 @@ public class UserRecallResponseBuilder { | ||
40 | private SknBaseInfoCacheBean sknBaseInfoCacheBean; | 38 | private SknBaseInfoCacheBean sknBaseInfoCacheBean; |
41 | @Autowired | 39 | @Autowired |
42 | private SearchDynamicConfigService searchDynamicConfigService; | 40 | private SearchDynamicConfigService searchDynamicConfigService; |
43 | - @Autowired | ||
44 | - private ProductListSortService productListSortService; | ||
45 | 41 | ||
46 | public UserRecallResponse builderRecallResult(RecallMergerResult recallMergerResult, UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) { | 42 | public UserRecallResponse builderRecallResult(RecallMergerResult recallMergerResult, UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) { |
47 | //1、获取总数 | 43 | //1、获取总数 |
@@ -60,17 +56,14 @@ public class UserRecallResponseBuilder { | @@ -60,17 +56,14 @@ public class UserRecallResponseBuilder { | ||
60 | //5、按相关性计算得分 | 56 | //5、按相关性计算得分 |
61 | sknResultList = this.doCalScoreAndSort(sknResultList, userRecallRequest.getUid(), userRecallRequest.getPageSize()); | 57 | sknResultList = this.doCalScoreAndSort(sknResultList, userRecallRequest.getUid(), userRecallRequest.getPageSize()); |
62 | 58 | ||
63 | - //6、品类品牌平衡 | ||
64 | - sknResultList = this.doBalance(sknResultList); | ||
65 | - | ||
66 | - //7、处理firstSkn-直通车等信息 | 59 | + //6、处理firstSkn-直通车等信息 |
67 | sknResultList = this.doReRank(sknResultList); | 60 | sknResultList = this.doReRank(sknResultList); |
68 | 61 | ||
69 | - //8、添加日志 | 62 | + //7、添加日志 |
70 | for (RecallMergerResult.SknResult sknResult : sknResultList) { | 63 | for (RecallMergerResult.SknResult sknResult : sknResultList) { |
71 | this.logSknStrategyAndScore(userRecallRequest, sknResult); | 64 | this.logSknStrategyAndScore(userRecallRequest, sknResult); |
72 | } | 65 | } |
73 | - //9、分页处理 | 66 | + //8、分页处理 |
74 | int pageSize = userRecallRequest.getPageSize(); | 67 | int pageSize = userRecallRequest.getPageSize(); |
75 | int recallTotalPage = (sknResultList.size() / pageSize); | 68 | int recallTotalPage = (sknResultList.size() / pageSize); |
76 | if (recallTotalPage == 0) { | 69 | if (recallTotalPage == 0) { |
@@ -79,13 +72,13 @@ public class UserRecallResponseBuilder { | @@ -79,13 +72,13 @@ public class UserRecallResponseBuilder { | ||
79 | recallTotalPage = Math.min(recallTotalPage, SknCountConstants.MAX_USER_RECALL_SKN_CACHE_COUNT / pageSize);//为用户最多保留X个skn进缓存 | 72 | recallTotalPage = Math.min(recallTotalPage, SknCountConstants.MAX_USER_RECALL_SKN_CACHE_COUNT / pageSize);//为用户最多保留X个skn进缓存 |
80 | sknResultList = CollectionUtils.safeSubList(sknResultList, 0, recallTotalPage * pageSize); | 73 | sknResultList = CollectionUtils.safeSubList(sknResultList, 0, recallTotalPage * pageSize); |
81 | 74 | ||
82 | - //10、构造返回结果 | 75 | + //9、构造返回结果 |
83 | List<RecallSknInfo> sknList = new ArrayList<>(); | 76 | List<RecallSknInfo> sknList = new ArrayList<>(); |
84 | for (RecallMergerResult.SknResult sknResult : sknResultList) { | 77 | for (RecallMergerResult.SknResult sknResult : sknResultList) { |
85 | sknList.add(new RecallSknInfo(sknResult.getProductSkn(), sknResult.getStrategy().name())); | 78 | sknList.add(new RecallSknInfo(sknResult.getProductSkn(), sknResult.getStrategy().name())); |
86 | } | 79 | } |
87 | int recallTotal = sknResultList.size(); | 80 | int recallTotal = sknResultList.size(); |
88 | - //11、打印日志 | 81 | + //10、打印日志 |
89 | logSknResultList(userRecallRequest, sknList); | 82 | logSknResultList(userRecallRequest, sknList); |
90 | return new UserRecallResponse(total, recallTotal, recallTotalPage, sknList); | 83 | return new UserRecallResponse(total, recallTotal, recallTotalPage, sknList); |
91 | } | 84 | } |
@@ -287,28 +280,6 @@ public class UserRecallResponseBuilder { | @@ -287,28 +280,6 @@ public class UserRecallResponseBuilder { | ||
287 | } | 280 | } |
288 | } | 281 | } |
289 | 282 | ||
290 | - | ||
291 | - /** | ||
292 | - * 精排-品类品牌平衡 | ||
293 | - * | ||
294 | - * @param sknResultList | ||
295 | - */ | ||
296 | - private List<RecallMergerResult.SknResult> doBalance(List<RecallMergerResult.SknResult> sknResultList) { | ||
297 | - List<RecallMergerResult.SknResult> results = productListSortService.sortProductList(sknResultList, new ProductListSortKey<RecallMergerResult.SknResult>() { | ||
298 | - @Override | ||
299 | - public String getSortKey(RecallMergerResult.SknResult product) { | ||
300 | - return new StringBuilder().append(product.getBrandId()).append("_").append(product.getMiddleSortId()).toString(); | ||
301 | - } | ||
302 | - | ||
303 | - @Override | ||
304 | - public int getMaxCount() { | ||
305 | - return 4; | ||
306 | - } | ||
307 | - }); | ||
308 | - return results; | ||
309 | - } | ||
310 | - | ||
311 | - | ||
312 | /** | 283 | /** |
313 | * 重排-处理直通车以及直通车 | 284 | * 重排-处理直通车以及直通车 |
314 | * | 285 | * |
@@ -329,11 +300,11 @@ public class UserRecallResponseBuilder { | @@ -329,11 +300,11 @@ public class UserRecallResponseBuilder { | ||
329 | } | 300 | } |
330 | } | 301 | } |
331 | 302 | ||
332 | - // 2、加入全部【除直通车、推荐、兜底】之外的商品 | 303 | + // 2、加入全部【除直通车和推荐】外的商品 |
333 | iterator = sknResultList.iterator(); | 304 | iterator = sknResultList.iterator(); |
334 | while (iterator.hasNext()) { | 305 | while (iterator.hasNext()) { |
335 | RecallMergerResult.SknResult sknResult = iterator.next(); | 306 | RecallMergerResult.SknResult sknResult = iterator.next(); |
336 | - if (!Arrays.asList(StrategyEnum.DIRECT_TRAIN, StrategyEnum.REC_SKN,StrategyEnum.COMMON,StrategyEnum.COMMON_RECALL_VALUE).contains(sknResult.getStrategy())) { | 307 | + if (!Arrays.asList(StrategyEnum.DIRECT_TRAIN, StrategyEnum.REC_SKN).contains(sknResult.getStrategy())) { |
337 | results.add(sknResult); | 308 | results.add(sknResult); |
338 | iterator.remove(); | 309 | iterator.remove(); |
339 | } | 310 | } |
@@ -346,10 +317,6 @@ public class UserRecallResponseBuilder { | @@ -346,10 +317,6 @@ public class UserRecallResponseBuilder { | ||
346 | int directTrainIndexInterval = searchDynamicConfigService.directTrainIndexInterval(); | 317 | int directTrainIndexInterval = searchDynamicConfigService.directTrainIndexInterval(); |
347 | this.addByIndexIndex(sknResultList, results, 4, directTrainIndexInterval, (sknResult -> StrategyEnum.DIRECT_TRAIN.equals(sknResult.getStrategy())), dropTransfer); | 318 | this.addByIndexIndex(sknResultList, results, 4, directTrainIndexInterval, (sknResult -> StrategyEnum.DIRECT_TRAIN.equals(sknResult.getStrategy())), dropTransfer); |
348 | 319 | ||
349 | - //5、插入兜底商品 | ||
350 | - if(!sknResultList.isEmpty()){ | ||
351 | - results.addAll(sknResultList); | ||
352 | - } | ||
353 | return results; | 320 | return results; |
354 | } | 321 | } |
355 | 322 |
-
Please register or login to post a comment