Authored by hugufei

fix bug

... ... @@ -195,7 +195,7 @@ public class UserRecallResponseBuilder {
continue;
}
//2)如果是推荐出来的,则单独加分[以减分的方式依次保证顺序]
if (strategy.equals(StrategyEnum.REC_SKN) || strategy.equals(StrategyEnum.RT_SIM_SKN)) {
if (strategy.equals(StrategyEnum.REC_SKN) || strategy.equals(StrategyEnum.RT_SIM_SKN) || strategy.equals(StrategyEnum.RT_YOUTUBE_SKN)){
sknResult.setScore((double) recommendSknIndex--);
continue;
}
... ...
... ... @@ -8,10 +8,11 @@ import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.base.utils.Transfer;
import com.yoho.search.cache.impls.CacheInterface;
import com.yoho.search.cache.impls.SearchRedis;
import com.yoho.search.common.SearchCommonService;
import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.core.es.model.SearchResult;
import com.yoho.search.service.recall.beans.strategy.StrategyEnum;
import com.yoho.search.service.recall.beans.persional.PageSknCodeBitSetComponent;
import com.yoho.search.service.recall.beans.strategy.StrategyEnum;
import com.yoho.search.service.recall.beans.strategy.impls.IRecallSknStrategy;
import com.yoho.search.service.recall.beans.strategy.impls.RealTimeSimilarSknStrategy;
import com.yoho.search.service.recall.beans.strategy.impls.RealTimeYoutuboSknStrategy;
... ... @@ -24,7 +25,6 @@ import com.yoho.search.service.recall.models.req.RecallRequest;
import com.yoho.search.service.recall.models.req.RecallRequestResponse;
import com.yoho.search.service.recall.models.req.RecallResponse;
import com.yoho.search.service.recall.models.req.UserRecallRequest;
import com.yoho.search.common.SearchCommonService;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.index.query.BoolQueryBuilder;
... ... @@ -70,24 +70,24 @@ public class SknRecallCacheBean {
int recSknCount = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.REC_SKN);
if (recSknCount > 0 && userPersonalFactor.getRecommendSknList() != null) {
filterSknList.addAll(userPersonalFactor.getRecommendSknList());
}else{
} else {
recSknCount = 0;
}
//2、获取相似skn的配置
int rtSimSknCount = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.RT_SIM_SKN);
if (rtSimSknCount > 0 && userPersonalFactor.getRealTimeSimilarSknList() != null) {
filterSknList.addAll(userPersonalFactor.getRealTimeSimilarSknList());
}else{
rtSimSknCount = 0;
}
//3、获取相似skn的配置
int youtubeSknCount = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.RT_YOUTUBE_SKN);
if (youtubeSknCount > 0 && userPersonalFactor.getRealTimeYoutubeSknList() != null) {
filterSknList.addAll(userPersonalFactor.getRealTimeYoutubeSknList());
}else{
} else {
youtubeSknCount = 0;
}
if(filterSknList.isEmpty()){
//3、获取相似skn的配置
int rtSimSknCount = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.RT_SIM_SKN);
if (rtSimSknCount > 0 && userPersonalFactor.getRealTimeSimilarSknList() != null) {
filterSknList.addAll(userPersonalFactor.getRealTimeSimilarSknList());
} else {
rtSimSknCount = 0;
}
if (filterSknList.isEmpty()) {
return new ArrayList<>();
}
//4、执行查询
... ... @@ -100,15 +100,15 @@ public class SknRecallCacheBean {
//5、构造结果
List<RecallRequestResponse> results = new ArrayList<>();
ParamQueryFilter paramQueryFilter = userRecallRequest.getParamQueryFilter();
if(recSknCount>0){
if (recSknCount > 0) {
results.addAll(this.buildResults(paramQueryFilter, userPersonalFactor.getRecommendSknList(), RecommendSknStrategy.class, filterSknResults, recSknCount));
}
if(rtSimSknCount>0){
results.addAll(this.buildResults(paramQueryFilter, userPersonalFactor.getRealTimeSimilarSknList(), RealTimeSimilarSknStrategy.class, filterSknResults, rtSimSknCount));
}
if(youtubeSknCount>0){
if (youtubeSknCount > 0) {
results.addAll(this.buildResults(paramQueryFilter, userPersonalFactor.getRealTimeYoutubeSknList(), RealTimeYoutuboSknStrategy.class, filterSknResults, youtubeSknCount));
}
if (rtSimSknCount > 0) {
results.addAll(this.buildResults(paramQueryFilter, userPersonalFactor.getRealTimeSimilarSknList(), RealTimeSimilarSknStrategy.class, filterSknResults, rtSimSknCount));
}
return results;
} catch (Exception e) {
RECALL_NEW_LOGGER.error(e.getMessage(), e);
... ... @@ -154,17 +154,17 @@ public class SknRecallCacheBean {
private List<Integer> filterRecommendWithCache(UserRecallRequest userRecallRequest, List<Integer> recommedSknList) {
//1、获取code版本
String codeVersion = zkConfigManager.getStringValueFromZk(ZkConfigConstants.productSknCodeVersion);
if(StringUtils.isBlank(codeVersion)){
if (StringUtils.isBlank(codeVersion)) {
return new ArrayList<>();
}
//2、查询sknCodeMap
Map<Integer, Integer> sknCodeMap = sknCodeCacheBean.queryProductSknCodeMap(codeVersion,recommedSknList);
Map<Integer, Integer> sknCodeMap = sknCodeCacheBean.queryProductSknCodeMap(codeVersion, recommedSknList);
if (sknCodeMap == null || sknCodeMap.isEmpty()) {
return new ArrayList<>();
}
ParamQueryFilter paramQueryFilter = userRecallRequest.getParamQueryFilter();
RedisKeyBuilder redisKeyBuilder = pageSknCodeBitSetComponent.genRedisKeyBuilder(paramQueryFilter,codeVersion);
RedisKeyBuilder redisKeyBuilder = pageSknCodeBitSetComponent.genRedisKeyBuilder(paramQueryFilter, codeVersion);
// //2、从本地缓存获取结果
// List<Integer> ehCacheResults = this.filterFromCache(ehCache, redisKeyBuilder, recommedSknList, sknCodeMap);
... ...
... ... @@ -12,7 +12,7 @@ public class StrategyHelper {
}
public static List<StrategyEnum> getIntervalStrategyEnums() {
return Arrays.asList(StrategyEnum.REC_SKN, StrategyEnum.RT_SIM_SKN,StrategyEnum.RT_YOUTUBE_SKN, StrategyEnum.DIRECT_TRAIN, StrategyEnum.ADD_FLOW, StrategyEnum.NEW_SHOP);
return Arrays.asList(StrategyEnum.REC_SKN, StrategyEnum.RT_YOUTUBE_SKN,StrategyEnum.RT_SIM_SKN, StrategyEnum.DIRECT_TRAIN, StrategyEnum.ADD_FLOW, StrategyEnum.NEW_SHOP);
}
}
... ...
... ... @@ -5,8 +5,8 @@ public enum StrategyEnum {
FIRST_SKN(110),//配置的skn
DIRECT_TRAIN(109),//直通车
REC_SKN(108),//实时推荐的skn
RT_SIM_SKN(107),//实时推荐的skn的相似skn
RT_YOUTUBE_SKN(106),//实时推荐的skn的相似skn
RT_YOUTUBE_SKN(107),//实时推荐的skn的相似skn
RT_SIM_SKN(106),//实时推荐的skn的相似skn
ADD_FLOW(105),//流量补偿
NEW_SHOP(104),//新开店铺
... ...