...
|
...
|
@@ -5,12 +5,13 @@ import com.yoho.search.core.personalized.PersonalizedSearch; |
|
|
import com.yoho.search.core.personalized.models.SortPriceAreas;
|
|
|
import com.yoho.search.recall.performance.beans.ProductFeatureFactorHepler;
|
|
|
import com.yoho.search.recall.performance.model.UserFeatureFactor;
|
|
|
import com.yoho.search.recall.scene.beans.cache.SknVectorResquestResponseCacheBean;
|
|
|
import com.yoho.search.recall.scene.beans.cache.SknBaseInfoCacheBean;
|
|
|
import com.yoho.search.recall.scene.beans.strategy.StrategyEnum;
|
|
|
import com.yoho.search.recall.scene.constants.SknCountConstants;
|
|
|
import com.yoho.search.recall.scene.models.common.RecallMergerResult;
|
|
|
import com.yoho.search.recall.scene.models.common.RecallSknInfo;
|
|
|
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;
|
...
|
...
|
@@ -37,7 +38,7 @@ public class UserRecallResponseBuilder { |
|
|
@Autowired
|
|
|
private ProductFeatureFactorHepler productFeatureFactorHepler;
|
|
|
@Autowired
|
|
|
private SknVectorResquestResponseCacheBean sknVectorResquestResponseCacheBean;
|
|
|
private SknBaseInfoCacheBean sknBaseInfoCacheBean;
|
|
|
@Autowired
|
|
|
private SearchDynamicConfigService searchDynamicConfigService;
|
|
|
|
...
|
...
|
@@ -47,20 +48,19 @@ public class UserRecallResponseBuilder { |
|
|
|
|
|
//2、获取召回结果中的所有skn
|
|
|
List<RecallMergerResult.SknResult> sknResultList = recallMergerResult.getSknList();
|
|
|
|
|
|
RECALL_NEW_LOGGER.info("total recall skn count after merger is [{}]", sknResultList.size());
|
|
|
|
|
|
//3、填充是否满足品类价格带的过滤
|
|
|
sknResultList = this.fillIsLikePriceArea(sknResultList, userPersonalFactor);
|
|
|
//3、填充skn基本信息
|
|
|
sknResultList = this.fillBaseInfo(sknResultList);
|
|
|
|
|
|
//4、填充skn向量
|
|
|
sknResultList = this.fillProductFactors(sknResultList);
|
|
|
//4、填充是否满足品类价格带的过滤
|
|
|
sknResultList = this.fillIsLikePriceArea(sknResultList, userPersonalFactor);
|
|
|
|
|
|
//5、按相关性计算得分
|
|
|
sknResultList = this.doCalScoreAndSort(sknResultList, userRecallRequest.getUid());
|
|
|
|
|
|
//6、品牌品类平衡
|
|
|
if(searchDynamicConfigService.searchPersionalNewStrategySortBrandBalance()){
|
|
|
if (searchDynamicConfigService.searchPersionalNewStrategySortBrandBalance()) {
|
|
|
sknResultList = this.doBalance(sknResultList);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -70,7 +70,7 @@ public class UserRecallResponseBuilder { |
|
|
//8、策略优先级排序并添加日志
|
|
|
for (RecallMergerResult.SknResult sknResult : sknResultList) {
|
|
|
Collections.sort(sknResult.getStrategys(), (o1, o2) -> o2.getPriority().compareTo(o1.getPriority()));
|
|
|
this.logSknStrategyAndScore(userRecallRequest,sknResult);
|
|
|
this.logSknStrategyAndScore(userRecallRequest, sknResult);
|
|
|
}
|
|
|
|
|
|
//9、分页处理
|
...
|
...
|
@@ -92,8 +92,30 @@ public class UserRecallResponseBuilder { |
|
|
return new UserRecallResponse(total, recallTotal, recallTotalPage, sknList);
|
|
|
}
|
|
|
|
|
|
private void logSknStrategyAndScore(UserRecallRequest userRecallRequest,RecallMergerResult.SknResult sknResult){
|
|
|
if(!userRecallRequest.openDetailLog()){
|
|
|
private List<RecallMergerResult.SknResult> fillBaseInfo(List<RecallMergerResult.SknResult> sknResultList) {
|
|
|
//1、请求构造
|
|
|
List<Integer> productSknList = new ArrayList<>();
|
|
|
for (RecallMergerResult.SknResult sknResult : sknResultList) {
|
|
|
productSknList.add(sknResult.getProductSkn());
|
|
|
}
|
|
|
//2、查询基本信息
|
|
|
Map<Integer, SknBaseInfoResponse> sknBaseInfoMap = sknBaseInfoCacheBean.querySknBaseInfo(productSknList);
|
|
|
|
|
|
//3、填充信息
|
|
|
for (RecallMergerResult.SknResult sknResult : sknResultList) {
|
|
|
SknBaseInfoResponse sknBaseInfo = sknBaseInfoMap.get(sknResult.getProductSkn());
|
|
|
if (sknBaseInfo == null) {
|
|
|
continue;
|
|
|
}
|
|
|
sknResult.setBySknBaseInfo(sknBaseInfo);
|
|
|
}
|
|
|
|
|
|
return sknResultList;
|
|
|
}
|
|
|
|
|
|
|
|
|
private void logSknStrategyAndScore(UserRecallRequest userRecallRequest, RecallMergerResult.SknResult sknResult) {
|
|
|
if (!userRecallRequest.openDetailLog()) {
|
|
|
return;
|
|
|
}
|
|
|
try {
|
...
|
...
|
@@ -113,8 +135,8 @@ public class UserRecallResponseBuilder { |
|
|
//1、获取用户价格带偏好
|
|
|
Map<Integer, List<Integer>> userMisort2PriceAreasMap = new HashMap<>();
|
|
|
List<SortPriceAreas> userSortPriceAreasList = userPersonalFactor.getSortPriceAreasList();
|
|
|
for (SortPriceAreas userSortPriceAreas: userSortPriceAreasList) {
|
|
|
userMisort2PriceAreasMap.put(userSortPriceAreas.getMisort(),userSortPriceAreas.getPriceAreas());
|
|
|
for (SortPriceAreas userSortPriceAreas : userSortPriceAreasList) {
|
|
|
userMisort2PriceAreasMap.put(userSortPriceAreas.getMisort(), userSortPriceAreas.getPriceAreas());
|
|
|
}
|
|
|
//2、填充当前skn是否属于用户偏好的价格带
|
|
|
for (RecallMergerResult.SknResult sknResult : sknResults) {
|
...
|
...
|
@@ -129,26 +151,6 @@ public class UserRecallResponseBuilder { |
|
|
return sknResults;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询skn的向量
|
|
|
*
|
|
|
* @param sknResults
|
|
|
* @return
|
|
|
*/
|
|
|
private List<RecallMergerResult.SknResult> fillProductFactors(List<RecallMergerResult.SknResult> sknResults) {
|
|
|
//1、请求构造
|
|
|
List<Integer> skns = new ArrayList<>();
|
|
|
for (RecallMergerResult.SknResult sknResult : sknResults) {
|
|
|
skns.add(sknResult.getProductSkn());
|
|
|
}
|
|
|
//2、执行查询
|
|
|
Map<Integer, String> productFactors = sknVectorResquestResponseCacheBean.querySknVectors(skns);
|
|
|
//3、填充向量
|
|
|
for (RecallMergerResult.SknResult sknResult : sknResults) {
|
|
|
sknResult.setFactor(MapUtils.getString(productFactors, sknResult.getProductSkn(), ""));
|
|
|
}
|
|
|
return sknResults;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 粗排-按相关性计算得分,并按得分排序
|
...
|
...
|
@@ -186,6 +188,7 @@ public class UserRecallResponseBuilder { |
|
|
|
|
|
/**
|
|
|
* 当前商品是否只是兜底策略找回来的
|
|
|
*
|
|
|
* @param sknResult
|
|
|
* @return
|
|
|
*/
|
...
|
...
|
@@ -196,7 +199,7 @@ public class UserRecallResponseBuilder { |
|
|
return true;
|
|
|
}
|
|
|
//2、只是兜底策略
|
|
|
if(strategys.size()==1 &&strategys.get(0).equals(StrategyEnum.COMMON) ){
|
|
|
if (strategys.size() == 1 && strategys.get(0).equals(StrategyEnum.COMMON)) {
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
...
|
...
|
|