1
|
package com.yoho.search.service.scorer;
|
1
|
package com.yoho.search.service.scorer;
|
2
|
|
2
|
|
3
|
-import java.util.ArrayList;
|
|
|
4
|
-import java.util.List;
|
|
|
5
|
-import java.util.Map;
|
|
|
6
|
-
|
|
|
7
|
-import org.elasticsearch.index.query.QueryBuilder;
|
|
|
8
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
9
|
-import org.springframework.stereotype.Component;
|
|
|
10
|
-
|
|
|
11
|
import com.yoho.search.core.personalized.BigDataRedisService;
|
3
|
import com.yoho.search.core.personalized.BigDataRedisService;
|
12
|
import com.yoho.search.models.FirstShelveTimeScore;
|
4
|
import com.yoho.search.models.FirstShelveTimeScore;
|
13
|
import com.yoho.search.service.base.SearchDynamicConfigService;
|
5
|
import com.yoho.search.service.base.SearchDynamicConfigService;
|
14
|
import com.yoho.search.service.base.SearchRequestParams;
|
6
|
import com.yoho.search.service.base.SearchRequestParams;
|
15
|
import com.yoho.search.service.helper.SearchCommonHelper;
|
7
|
import com.yoho.search.service.helper.SearchCommonHelper;
|
16
|
-import com.yoho.search.service.scorer.impl.AddScoreSknScorer;
|
|
|
17
|
-import com.yoho.search.service.scorer.impl.BreakSizeProductScorer;
|
|
|
18
|
-import com.yoho.search.service.scorer.impl.FeatureFactorScorer;
|
|
|
19
|
-import com.yoho.search.service.scorer.impl.FirstProductSknScorer;
|
|
|
20
|
-import com.yoho.search.service.scorer.impl.FirstShelveTimeScorer;
|
|
|
21
|
-import com.yoho.search.service.scorer.impl.GlobalProductScorer;
|
|
|
22
|
-import com.yoho.search.service.scorer.impl.NewArriveHeatDescScorer;
|
|
|
23
|
-import com.yoho.search.service.scorer.impl.ProblemProductScorer;
|
|
|
24
|
-import com.yoho.search.service.scorer.impl.RandomScorer;
|
|
|
25
|
-import com.yoho.search.service.scorer.impl.UserChannelSearchScorer;
|
8
|
+import com.yoho.search.service.scorer.impl.*;
|
|
|
9
|
+import org.elasticsearch.index.query.QueryBuilder;
|
|
|
10
|
+import org.slf4j.Logger;
|
|
|
11
|
+import org.slf4j.LoggerFactory;
|
|
|
12
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
13
|
+import org.springframework.stereotype.Component;
|
|
|
14
|
+
|
|
|
15
|
+import java.util.ArrayList;
|
|
|
16
|
+import java.util.List;
|
|
|
17
|
+import java.util.Map;
|
26
|
|
18
|
|
27
|
@Component
|
19
|
@Component
|
28
|
public class SearchScorerFactory {
|
20
|
public class SearchScorerFactory {
|
29
|
|
21
|
|
|
|
22
|
+ private static final Logger logger = LoggerFactory.getLogger(SearchScorerFactory.class);
|
|
|
23
|
+
|
30
|
@Autowired
|
24
|
@Autowired
|
31
|
private BigDataRedisService bigDataRedisService;
|
25
|
private BigDataRedisService bigDataRedisService;
|
32
|
@Autowired
|
26
|
@Autowired
|
|
@@ -44,9 +38,15 @@ public class SearchScorerFactory { |
|
@@ -44,9 +38,15 @@ public class SearchScorerFactory { |
44
|
|
38
|
|
45
|
// 获取【断码商品】的打分器
|
39
|
// 获取【断码商品】的打分器
|
46
|
public IScorer getBreakSizeProductScorer(Map<String, String> paramMap) {
|
40
|
public IScorer getBreakSizeProductScorer(Map<String, String> paramMap) {
|
47
|
- List<String> userFavoriteSizes = bigDataRedisService.getUserFavoriteSizes(paramMap.getOrDefault("uid", "0"));
|
|
|
48
|
- IScorer breakSizeProductScorer = new BreakSizeProductScorer(userFavoriteSizes);
|
|
|
49
|
- return breakSizeProductScorer;
|
41
|
+ try {
|
|
|
42
|
+ List<String> userFavoriteSizes = bigDataRedisService.getUserFavoriteSizes(paramMap.getOrDefault("uid", "0"));
|
|
|
43
|
+ IScorer breakSizeProductScorer = new BreakSizeProductScorer(userFavoriteSizes);
|
|
|
44
|
+ return breakSizeProductScorer;
|
|
|
45
|
+ }catch (Exception e){
|
|
|
46
|
+ logger.error(e.getMessage());
|
|
|
47
|
+ return null;
|
|
|
48
|
+ }
|
|
|
49
|
+
|
50
|
}
|
50
|
}
|
51
|
|
51
|
|
52
|
// 获取【问题商品】的打分器
|
52
|
// 获取【问题商品】的打分器
|
|
@@ -61,12 +61,17 @@ public class SearchScorerFactory { |
|
@@ -61,12 +61,17 @@ public class SearchScorerFactory { |
61
|
|
61
|
|
62
|
// 获取【模糊搜索页针对频道】的打分器
|
62
|
// 获取【模糊搜索页针对频道】的打分器
|
63
|
public IScorer getChannelSearchScorer(Map<String, String> paramMap) {
|
63
|
public IScorer getChannelSearchScorer(Map<String, String> paramMap) {
|
64
|
- if (!searchCommonHelper.isNeedDeScoreForChannel(paramMap)) {
|
64
|
+ try {
|
|
|
65
|
+ if (!searchCommonHelper.isNeedDeScoreForChannel(paramMap)) {
|
|
|
66
|
+ return null;
|
|
|
67
|
+ }
|
|
|
68
|
+ float physicalChannelWeight = (float) dynamicConfig.getDeScorePhysicalChannelWeight();
|
|
|
69
|
+ Map<String, Float> userGenderFloat = bigDataRedisService.getUserGenderFeature(paramMap.getOrDefault("uid", "0"));
|
|
|
70
|
+ return new UserChannelSearchScorer(paramMap, userGenderFloat, physicalChannelWeight);
|
|
|
71
|
+ }catch (Exception e){
|
|
|
72
|
+ logger.error(e.getMessage());
|
65
|
return null;
|
73
|
return null;
|
66
|
}
|
74
|
}
|
67
|
- float physicalChannelWeight = (float) dynamicConfig.getDeScorePhysicalChannelWeight();
|
|
|
68
|
- Map<String, Float> userGenderFloat = bigDataRedisService.getUserGenderFeature(paramMap.getOrDefault("uid", "0"));
|
|
|
69
|
- return new UserChannelSearchScorer(paramMap, userGenderFloat, physicalChannelWeight);
|
|
|
70
|
}
|
75
|
}
|
71
|
|
76
|
|
72
|
// 获取【firstProductSkn】的打分器
|
77
|
// 获取【firstProductSkn】的打分器
|
|
@@ -101,9 +106,4 @@ public class SearchScorerFactory { |
|
@@ -101,9 +106,4 @@ public class SearchScorerFactory { |
101
|
return new FeatureFactorScorer(scoreFilter, featureFactors, featureVersion);
|
106
|
return new FeatureFactorScorer(scoreFilter, featureFactors, featureVersion);
|
102
|
}
|
107
|
}
|
103
|
|
108
|
|
104
|
- // 获取【随机函数】的打分器
|
|
|
105
|
- public IScorer getRandomScorer(String seed) {
|
|
|
106
|
- return new RandomScorer(seed);
|
|
|
107
|
- }
|
|
|
108
|
-
|
|
|
109
|
} |
109
|
} |