...
|
...
|
@@ -15,8 +15,6 @@ import com.yoho.search.recall.scene.models.personal.UserPersonalFactor; |
|
|
import com.yoho.search.recall.scene.models.req.SknBaseInfoResponse;
|
|
|
import com.yoho.search.recall.scene.models.req.UserRecallRequest;
|
|
|
import com.yoho.search.recall.scene.models.req.UserRecallResponse;
|
|
|
import com.yoho.search.service.base.ProductListSortKey;
|
|
|
import com.yoho.search.service.base.ProductListSortService;
|
|
|
import com.yoho.search.service.base.SearchDynamicConfigService;
|
|
|
import com.yoho.search.service.scorer.personal.PersonalVectorFeatureSearch;
|
|
|
import org.slf4j.Logger;
|
...
|
...
|
@@ -40,8 +38,6 @@ public class UserRecallResponseBuilder { |
|
|
private SknBaseInfoCacheBean sknBaseInfoCacheBean;
|
|
|
@Autowired
|
|
|
private SearchDynamicConfigService searchDynamicConfigService;
|
|
|
@Autowired
|
|
|
private ProductListSortService productListSortService;
|
|
|
|
|
|
public UserRecallResponse builderRecallResult(RecallMergerResult recallMergerResult, UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) {
|
|
|
//1、获取总数
|
...
|
...
|
@@ -60,17 +56,14 @@ public class UserRecallResponseBuilder { |
|
|
//5、按相关性计算得分
|
|
|
sknResultList = this.doCalScoreAndSort(sknResultList, userRecallRequest.getUid(), userRecallRequest.getPageSize());
|
|
|
|
|
|
//6、品类品牌平衡
|
|
|
sknResultList = this.doBalance(sknResultList);
|
|
|
|
|
|
//7、处理firstSkn-直通车等信息
|
|
|
//6、处理firstSkn-直通车等信息
|
|
|
sknResultList = this.doReRank(sknResultList);
|
|
|
|
|
|
//8、添加日志
|
|
|
//7、添加日志
|
|
|
for (RecallMergerResult.SknResult sknResult : sknResultList) {
|
|
|
this.logSknStrategyAndScore(userRecallRequest, sknResult);
|
|
|
}
|
|
|
//9、分页处理
|
|
|
//8、分页处理
|
|
|
int pageSize = userRecallRequest.getPageSize();
|
|
|
int recallTotalPage = (sknResultList.size() / pageSize);
|
|
|
if (recallTotalPage == 0) {
|
...
|
...
|
@@ -79,13 +72,13 @@ public class UserRecallResponseBuilder { |
|
|
recallTotalPage = Math.min(recallTotalPage, SknCountConstants.MAX_USER_RECALL_SKN_CACHE_COUNT / pageSize);//为用户最多保留X个skn进缓存
|
|
|
sknResultList = CollectionUtils.safeSubList(sknResultList, 0, recallTotalPage * pageSize);
|
|
|
|
|
|
//10、构造返回结果
|
|
|
//9、构造返回结果
|
|
|
List<RecallSknInfo> sknList = new ArrayList<>();
|
|
|
for (RecallMergerResult.SknResult sknResult : sknResultList) {
|
|
|
sknList.add(new RecallSknInfo(sknResult.getProductSkn(), sknResult.getStrategy().name()));
|
|
|
}
|
|
|
int recallTotal = sknResultList.size();
|
|
|
//11、打印日志
|
|
|
//10、打印日志
|
|
|
logSknResultList(userRecallRequest, sknList);
|
|
|
return new UserRecallResponse(total, recallTotal, recallTotalPage, sknList);
|
|
|
}
|
...
|
...
|
@@ -287,28 +280,6 @@ public class UserRecallResponseBuilder { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 精排-品类品牌平衡
|
|
|
*
|
|
|
* @param sknResultList
|
|
|
*/
|
|
|
private List<RecallMergerResult.SknResult> doBalance(List<RecallMergerResult.SknResult> sknResultList) {
|
|
|
List<RecallMergerResult.SknResult> results = productListSortService.sortProductList(sknResultList, new ProductListSortKey<RecallMergerResult.SknResult>() {
|
|
|
@Override
|
|
|
public String getSortKey(RecallMergerResult.SknResult product) {
|
|
|
return new StringBuilder().append(product.getBrandId()).append("_").append(product.getMiddleSortId()).toString();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int getMaxCount() {
|
|
|
return 4;
|
|
|
}
|
|
|
});
|
|
|
return results;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 重排-处理直通车以及直通车
|
|
|
*
|
...
|
...
|
@@ -329,11 +300,11 @@ public class UserRecallResponseBuilder { |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 2、加入全部【除直通车、推荐、兜底】之外的商品
|
|
|
// 2、加入全部【除直通车和推荐】外的商品
|
|
|
iterator = sknResultList.iterator();
|
|
|
while (iterator.hasNext()) {
|
|
|
RecallMergerResult.SknResult sknResult = iterator.next();
|
|
|
if (!Arrays.asList(StrategyEnum.DIRECT_TRAIN, StrategyEnum.REC_SKN,StrategyEnum.COMMON,StrategyEnum.COMMON_RECALL_VALUE).contains(sknResult.getStrategy())) {
|
|
|
if (!Arrays.asList(StrategyEnum.DIRECT_TRAIN, StrategyEnum.REC_SKN).contains(sknResult.getStrategy())) {
|
|
|
results.add(sknResult);
|
|
|
iterator.remove();
|
|
|
}
|
...
|
...
|
@@ -346,10 +317,6 @@ public class UserRecallResponseBuilder { |
|
|
int directTrainIndexInterval = searchDynamicConfigService.directTrainIndexInterval();
|
|
|
this.addByIndexIndex(sknResultList, results, 4, directTrainIndexInterval, (sknResult -> StrategyEnum.DIRECT_TRAIN.equals(sknResult.getStrategy())), dropTransfer);
|
|
|
|
|
|
//5、插入兜底商品
|
|
|
if(!sknResultList.isEmpty()){
|
|
|
results.addAll(sknResultList);
|
|
|
}
|
|
|
return results;
|
|
|
}
|
|
|
|
...
|
...
|
|