|
|
package com.yoho.search.service.scorer;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import org.elasticsearch.index.query.QueryBuilder;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import com.yoho.search.core.personalized.BigDataRedisService;
|
|
|
import com.yoho.search.models.FirstShelveTimeScore;
|
|
|
import com.yoho.search.service.base.SearchDynamicConfigService;
|
|
|
import com.yoho.search.service.base.SearchRequestParams;
|
|
|
import com.yoho.search.service.helper.SearchCommonHelper;
|
|
|
import com.yoho.search.service.scorer.impl.AddScoreSknScorer;
|
|
|
import com.yoho.search.service.scorer.impl.BreakSizeProductScorer;
|
|
|
import com.yoho.search.service.scorer.impl.FeatureFactorScorer;
|
|
|
import com.yoho.search.service.scorer.impl.FirstProductSknScorer;
|
|
|
import com.yoho.search.service.scorer.impl.FirstShelveTimeScorer;
|
|
|
import com.yoho.search.service.scorer.impl.GlobalProductScorer;
|
|
|
import com.yoho.search.service.scorer.impl.NewArriveHeatDescScorer;
|
|
|
import com.yoho.search.service.scorer.impl.ProblemProductScorer;
|
|
|
import com.yoho.search.service.scorer.impl.RandomScorer;
|
|
|
import com.yoho.search.service.scorer.impl.UserChannelSearchScorer;
|
|
|
import com.yoho.search.service.scorer.impl.*;
|
|
|
import org.elasticsearch.index.query.QueryBuilder;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Component
|
|
|
public class SearchScorerFactory {
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(SearchScorerFactory.class);
|
|
|
|
|
|
@Autowired
|
|
|
private BigDataRedisService bigDataRedisService;
|
|
|
@Autowired
|
...
|
...
|
@@ -44,9 +38,15 @@ public class SearchScorerFactory { |
|
|
|
|
|
// 获取【断码商品】的打分器
|
|
|
public IScorer getBreakSizeProductScorer(Map<String, String> paramMap) {
|
|
|
List<String> userFavoriteSizes = bigDataRedisService.getUserFavoriteSizes(paramMap.getOrDefault("uid", "0"));
|
|
|
IScorer breakSizeProductScorer = new BreakSizeProductScorer(userFavoriteSizes);
|
|
|
return breakSizeProductScorer;
|
|
|
try {
|
|
|
List<String> userFavoriteSizes = bigDataRedisService.getUserFavoriteSizes(paramMap.getOrDefault("uid", "0"));
|
|
|
IScorer breakSizeProductScorer = new BreakSizeProductScorer(userFavoriteSizes);
|
|
|
return breakSizeProductScorer;
|
|
|
}catch (Exception e){
|
|
|
logger.error(e.getMessage());
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// 获取【问题商品】的打分器
|
...
|
...
|
@@ -61,12 +61,17 @@ public class SearchScorerFactory { |
|
|
|
|
|
// 获取【模糊搜索页针对频道】的打分器
|
|
|
public IScorer getChannelSearchScorer(Map<String, String> paramMap) {
|
|
|
if (!searchCommonHelper.isNeedDeScoreForChannel(paramMap)) {
|
|
|
try {
|
|
|
if (!searchCommonHelper.isNeedDeScoreForChannel(paramMap)) {
|
|
|
return null;
|
|
|
}
|
|
|
float physicalChannelWeight = (float) dynamicConfig.getDeScorePhysicalChannelWeight();
|
|
|
Map<String, Float> userGenderFloat = bigDataRedisService.getUserGenderFeature(paramMap.getOrDefault("uid", "0"));
|
|
|
return new UserChannelSearchScorer(paramMap, userGenderFloat, physicalChannelWeight);
|
|
|
}catch (Exception e){
|
|
|
logger.error(e.getMessage());
|
|
|
return null;
|
|
|
}
|
|
|
float physicalChannelWeight = (float) dynamicConfig.getDeScorePhysicalChannelWeight();
|
|
|
Map<String, Float> userGenderFloat = bigDataRedisService.getUserGenderFeature(paramMap.getOrDefault("uid", "0"));
|
|
|
return new UserChannelSearchScorer(paramMap, userGenderFloat, physicalChannelWeight);
|
|
|
}
|
|
|
|
|
|
// 获取【firstProductSkn】的打分器
|
...
|
...
|
@@ -101,9 +106,4 @@ public class SearchScorerFactory { |
|
|
return new FeatureFactorScorer(scoreFilter, featureFactors, featureVersion);
|
|
|
}
|
|
|
|
|
|
// 获取【随机函数】的打分器
|
|
|
public IScorer getRandomScorer(String seed) {
|
|
|
return new RandomScorer(seed);
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|