...
|
...
|
@@ -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);
|
...
|
...
|
|