...
|
...
|
@@ -2,6 +2,7 @@ package com.yoho.search.recall.scene.beans.builder; |
|
|
|
|
|
import com.yoho.search.base.utils.CollectionUtils;
|
|
|
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;
|
...
|
...
|
@@ -14,6 +15,7 @@ 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.apache.commons.collections.MapUtils;
|
|
|
import org.slf4j.Logger;
|
...
|
...
|
@@ -36,6 +38,8 @@ public class UserRecallResponseBuilder { |
|
|
private ProductFeatureFactorHepler productFeatureFactorHepler;
|
|
|
@Autowired
|
|
|
private SknVectorResquestResponseCacheBean sknVectorResquestResponseCacheBean;
|
|
|
@Autowired
|
|
|
private SearchDynamicConfigService searchDynamicConfigService;
|
|
|
|
|
|
public UserRecallResponse builderRecallResult(RecallMergerResult recallMergerResult, UserRecallRequest param, UserPersonalFactor userPersonalFactor) {
|
|
|
//1、获取总数
|
...
|
...
|
@@ -73,7 +77,9 @@ public class UserRecallResponseBuilder { |
|
|
//8、构造返回结果
|
|
|
List<RecallSknInfo> sknList = new ArrayList<>();
|
|
|
for (RecallMergerResult.SknResult sknResult : sknResultList) {
|
|
|
String requestType = sknResult.getStrategys().get(0).name();//已经按优先级排序好了,取第一个就行
|
|
|
//按优先级排序,去第一种召回策略
|
|
|
Collections.sort(sknResult.getStrategys(), (o1, o2) -> o2.getPriority().compareTo(o1.getPriority()));
|
|
|
String requestType = sknResult.getStrategys().get(0).name();
|
|
|
sknList.add(new RecallSknInfo(sknResult.getProductSkn(), requestType));
|
|
|
}
|
|
|
int recallTotal = sknResultList.size();
|
...
|
...
|
@@ -87,10 +93,16 @@ public class UserRecallResponseBuilder { |
|
|
* @return
|
|
|
*/
|
|
|
private List<RecallMergerResult.SknResult> fillIsLikePriceArea(List<RecallMergerResult.SknResult> sknResults, UserPersonalFactor userPersonalFactor) {
|
|
|
Map<Integer, List<Integer>> misort2PriceAreas = new HashMap<>();
|
|
|
//1、获取用户价格带偏好
|
|
|
Map<Integer, List<Integer>> userMisort2PriceAreasMap = new HashMap<>();
|
|
|
List<SortPriceAreas> userSortPriceAreasList = userPersonalFactor.getSortPriceAreasList();
|
|
|
for (SortPriceAreas userSortPriceAreas: userSortPriceAreasList) {
|
|
|
userMisort2PriceAreasMap.put(userSortPriceAreas.getMisort(),userSortPriceAreas.getPriceAreas());
|
|
|
}
|
|
|
//2、填充当前skn是否属于用户偏好的价格带
|
|
|
for (RecallMergerResult.SknResult sknResult : sknResults) {
|
|
|
Integer misortId = sknResult.getMiddleSortId();
|
|
|
List<Integer> priceAreas = misort2PriceAreas.getOrDefault(misortId, new ArrayList<>());
|
|
|
List<Integer> priceAreas = userMisort2PriceAreasMap.getOrDefault(misortId, new ArrayList<>());
|
|
|
if (priceAreas.contains(sknResult.getPriceArea())) {
|
|
|
sknResult.setLikePriceArea(true);
|
|
|
} else {
|
...
|
...
|
@@ -140,8 +152,8 @@ public class UserRecallResponseBuilder { |
|
|
if (sknResult.isLikePriceArea()) {
|
|
|
score = score + 100;
|
|
|
}
|
|
|
//2)如果是个性化召回来的,则加分
|
|
|
if (this.isPersonalRecall(sknResult)) {
|
|
|
//2)判断兜底的数据是否参与评分
|
|
|
if(!searchDynamicConfigService.searchPersionalNewStrategyCommonJoinScoreOpen() && !this.isCommonRecallOnly(sknResult)){
|
|
|
score = score + 50;
|
|
|
}
|
|
|
sknResult.setScore(score);
|
...
|
...
|
@@ -151,20 +163,17 @@ public class UserRecallResponseBuilder { |
|
|
return sknResultList;
|
|
|
}
|
|
|
|
|
|
private boolean isPersonalRecall(RecallMergerResult.SknResult sknResult) {
|
|
|
private boolean isCommonRecallOnly(RecallMergerResult.SknResult sknResult) {
|
|
|
List<StrategyEnum> strategys = sknResult.getStrategys();
|
|
|
//1、非空判断
|
|
|
if (strategys == null || strategys.isEmpty()) {
|
|
|
return false;
|
|
|
return true;
|
|
|
}
|
|
|
//2、按优先级排序-分数越高的越排在前面
|
|
|
Collections.sort(strategys, (o1, o2) -> (-1) * (o1.getPriority().compareTo(o2.getPriority())));
|
|
|
|
|
|
//3、判断是否只有兜底
|
|
|
if (strategys.get(0).equals(StrategyEnum.COMMON)) {
|
|
|
return false;
|
|
|
//2、只是兜底策略
|
|
|
if(strategys.size()==1 &&strategys.get(0).equals(StrategyEnum.COMMON) ){
|
|
|
return true;
|
|
|
}
|
|
|
return true;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
|