Showing
5 changed files
with
120 additions
and
232 deletions
1 | -package com.yoho.search.recall.scene.beans.helper; | ||
2 | - | ||
3 | -import com.yoho.search.recall.scene.beans.strategy.StrategyEnum; | ||
4 | - | ||
5 | -public class StrategyHelper { | ||
6 | - | ||
7 | - public static boolean isCommonStrategy(StrategyEnum strategy) { | ||
8 | - return strategy.equals(StrategyEnum.COMMON_CTR_VALUE) || strategy.equals(StrategyEnum.COMMON_HEAT_VALUE); | ||
9 | - } | ||
10 | -} | 1 | +package com.yoho.search.recall.scene.beans.helper; |
2 | + | ||
3 | +import com.yoho.search.recall.scene.beans.strategy.StrategyEnum; | ||
4 | + | ||
5 | +public class StrategyHelper { | ||
6 | + | ||
7 | + public static boolean isCommonStrategy(StrategyEnum strategy) { | ||
8 | + return strategy.equals(StrategyEnum.COMMON_CTR_VALUE) || strategy.equals(StrategyEnum.COMMON_HEAT_VALUE); | ||
9 | + } | ||
10 | +} |
1 | -package com.yoho.search.recall.scene.beans.strategy.impls; | ||
2 | - | ||
3 | -import com.yoho.search.recall.scene.beans.helper.SortBuilderHelper; | ||
4 | -import com.yoho.search.recall.scene.beans.strategy.IStrategy; | ||
5 | -import com.yoho.search.recall.scene.beans.strategy.StrategyEnum; | ||
6 | -import com.yoho.search.recall.scene.constants.CacheTimeConstants; | ||
7 | -import org.elasticsearch.index.query.QueryBuilder; | ||
8 | -import org.elasticsearch.search.sort.SortBuilder; | ||
9 | - | ||
10 | -/** | ||
11 | - * 直通车的召回 | ||
12 | - * | ||
13 | - * @author gufei.hu | ||
14 | - * | ||
15 | - */ | ||
16 | -public class CommonCtrValueStrategy implements IStrategy { | ||
17 | - | ||
18 | - private int size; | ||
19 | - | ||
20 | - public CommonCtrValueStrategy(int size) { | ||
21 | - this.size = size; | ||
22 | - } | ||
23 | - | ||
24 | - @Override | ||
25 | - public StrategyEnum strategtEnum() { | ||
26 | - return StrategyEnum.COMMON_CTR_VALUE; | ||
27 | - } | ||
28 | - | ||
29 | - @Override | ||
30 | - public QueryBuilder extendFilter() { | ||
31 | - return null; | ||
32 | - } | ||
33 | - | ||
34 | - @Override | ||
35 | - public SortBuilder<?> sortBuilder() { | ||
36 | - return SortBuilderHelper.getCtrValueDescSort(); | ||
37 | - } | ||
38 | - | ||
39 | - @Override | ||
40 | - public int size() { | ||
41 | - return size; | ||
42 | - } | ||
43 | - | ||
44 | - @Override | ||
45 | - public int cacheTimeInMinute() { | ||
46 | - return CacheTimeConstants.COMMON_RECALL_STRATEGY_CACHE_TIME; | ||
47 | - } | ||
48 | - | ||
49 | - @Override | ||
50 | - public String strategyCacheKey() { | ||
51 | - StringBuilder sb = defaultStrategyKey(); | ||
52 | - return sb.toString(); | ||
53 | - } | ||
54 | - | ||
55 | -} | 1 | +package com.yoho.search.recall.scene.beans.strategy.impls; |
2 | + | ||
3 | +import com.yoho.search.recall.scene.beans.helper.SortBuilderHelper; | ||
4 | +import com.yoho.search.recall.scene.beans.strategy.IStrategy; | ||
5 | +import com.yoho.search.recall.scene.beans.strategy.StrategyEnum; | ||
6 | +import com.yoho.search.recall.scene.constants.CacheTimeConstants; | ||
7 | +import org.elasticsearch.index.query.QueryBuilder; | ||
8 | +import org.elasticsearch.search.sort.SortBuilder; | ||
9 | + | ||
10 | +/** | ||
11 | + * 直通车的召回 | ||
12 | + * | ||
13 | + * @author gufei.hu | ||
14 | + * | ||
15 | + */ | ||
16 | +public class CommonCtrValueStrategy implements IStrategy { | ||
17 | + | ||
18 | + private int size; | ||
19 | + | ||
20 | + public CommonCtrValueStrategy(int size) { | ||
21 | + this.size = size; | ||
22 | + } | ||
23 | + | ||
24 | + @Override | ||
25 | + public StrategyEnum strategtEnum() { | ||
26 | + return StrategyEnum.COMMON_CTR_VALUE; | ||
27 | + } | ||
28 | + | ||
29 | + @Override | ||
30 | + public QueryBuilder extendFilter() { | ||
31 | + return null; | ||
32 | + } | ||
33 | + | ||
34 | + @Override | ||
35 | + public SortBuilder<?> sortBuilder() { | ||
36 | + return SortBuilderHelper.getCtrValueDescSort(); | ||
37 | + } | ||
38 | + | ||
39 | + @Override | ||
40 | + public int size() { | ||
41 | + return size; | ||
42 | + } | ||
43 | + | ||
44 | + @Override | ||
45 | + public int cacheTimeInMinute() { | ||
46 | + return CacheTimeConstants.COMMON_RECALL_STRATEGY_CACHE_TIME; | ||
47 | + } | ||
48 | + | ||
49 | + @Override | ||
50 | + public String strategyCacheKey() { | ||
51 | + StringBuilder sb = defaultStrategyKey(); | ||
52 | + return sb.toString(); | ||
53 | + } | ||
54 | + | ||
55 | +} |
service/src/main/java/com/yoho/search/recall/scene/beans/strategy/impls/CommonHeatValueStrategy.java
1 | -package com.yoho.search.recall.scene.beans.strategy.impls; | ||
2 | - | ||
3 | -import com.yoho.search.recall.scene.beans.helper.SortBuilderHelper; | ||
4 | -import com.yoho.search.recall.scene.beans.strategy.IStrategy; | ||
5 | -import com.yoho.search.recall.scene.beans.strategy.StrategyEnum; | ||
6 | -import com.yoho.search.recall.scene.constants.CacheTimeConstants; | ||
7 | -import org.elasticsearch.index.query.QueryBuilder; | ||
8 | -import org.elasticsearch.search.sort.SortBuilder; | ||
9 | - | ||
10 | -/** | ||
11 | - * 按人气兜底的召回 | ||
12 | - * | ||
13 | - * @author gufei.hu | ||
14 | - * | ||
15 | - */ | ||
16 | -public class CommonHeatValueStrategy implements IStrategy { | ||
17 | - | ||
18 | - private int size; | ||
19 | - | ||
20 | - public CommonHeatValueStrategy(int size) { | ||
21 | - this.size = size; | ||
22 | - } | ||
23 | - | ||
24 | - @Override | ||
25 | - public StrategyEnum strategtEnum() { | ||
26 | - return StrategyEnum.COMMON_HEAT_VALUE; | ||
27 | - } | ||
28 | - | ||
29 | - @Override | ||
30 | - public QueryBuilder extendFilter() { | ||
31 | - return null; | ||
32 | - } | ||
33 | - | ||
34 | - @Override | ||
35 | - public SortBuilder<?> sortBuilder() { | ||
36 | - return SortBuilderHelper.getHeatValueDescSort(); | ||
37 | - } | ||
38 | - | ||
39 | - @Override | ||
40 | - public int size() { | ||
41 | - return size; | ||
42 | - } | ||
43 | - | ||
44 | - @Override | ||
45 | - public int cacheTimeInMinute() { | ||
46 | - return CacheTimeConstants.COMMON_RECALL_STRATEGY_CACHE_TIME; | ||
47 | - } | ||
48 | - | ||
49 | - @Override | ||
50 | - public String strategyCacheKey() { | ||
51 | - StringBuilder sb = defaultStrategyKey(); | ||
52 | - return sb.toString(); | ||
53 | - } | ||
54 | - | ||
55 | -} | 1 | +package com.yoho.search.recall.scene.beans.strategy.impls; |
2 | + | ||
3 | +import com.yoho.search.recall.scene.beans.helper.SortBuilderHelper; | ||
4 | +import com.yoho.search.recall.scene.beans.strategy.IStrategy; | ||
5 | +import com.yoho.search.recall.scene.beans.strategy.StrategyEnum; | ||
6 | +import com.yoho.search.recall.scene.constants.CacheTimeConstants; | ||
7 | +import org.elasticsearch.index.query.QueryBuilder; | ||
8 | +import org.elasticsearch.search.sort.SortBuilder; | ||
9 | + | ||
10 | +/** | ||
11 | + * 按人气兜底的召回 | ||
12 | + * | ||
13 | + * @author gufei.hu | ||
14 | + * | ||
15 | + */ | ||
16 | +public class CommonHeatValueStrategy implements IStrategy { | ||
17 | + | ||
18 | + private int size; | ||
19 | + | ||
20 | + public CommonHeatValueStrategy(int size) { | ||
21 | + this.size = size; | ||
22 | + } | ||
23 | + | ||
24 | + @Override | ||
25 | + public StrategyEnum strategtEnum() { | ||
26 | + return StrategyEnum.COMMON_HEAT_VALUE; | ||
27 | + } | ||
28 | + | ||
29 | + @Override | ||
30 | + public QueryBuilder extendFilter() { | ||
31 | + return null; | ||
32 | + } | ||
33 | + | ||
34 | + @Override | ||
35 | + public SortBuilder<?> sortBuilder() { | ||
36 | + return SortBuilderHelper.getHeatValueDescSort(); | ||
37 | + } | ||
38 | + | ||
39 | + @Override | ||
40 | + public int size() { | ||
41 | + return size; | ||
42 | + } | ||
43 | + | ||
44 | + @Override | ||
45 | + public int cacheTimeInMinute() { | ||
46 | + return CacheTimeConstants.COMMON_RECALL_STRATEGY_CACHE_TIME; | ||
47 | + } | ||
48 | + | ||
49 | + @Override | ||
50 | + public String strategyCacheKey() { | ||
51 | + StringBuilder sb = defaultStrategyKey(); | ||
52 | + return sb.toString(); | ||
53 | + } | ||
54 | + | ||
55 | +} |
1 | -package com.yoho.search.recall.scene.beans.strategy.impls; | ||
2 | - | ||
3 | -import com.yoho.search.recall.scene.beans.helper.ExtendFilterHelper; | ||
4 | -import com.yoho.search.recall.scene.beans.helper.SortBuilderHelper; | ||
5 | -import com.yoho.search.recall.scene.beans.strategy.IStrategy; | ||
6 | -import com.yoho.search.recall.scene.beans.strategy.StrategyEnum; | ||
7 | -import com.yoho.search.recall.scene.constants.CacheTimeConstants; | ||
8 | -import org.elasticsearch.index.query.QueryBuilder; | ||
9 | -import org.elasticsearch.search.sort.SortBuilder; | ||
10 | - | ||
11 | -/** | ||
12 | - * 直通车的召回 | ||
13 | - * | ||
14 | - * @author gufei.hu | ||
15 | - * | ||
16 | - */ | ||
17 | -public class CommonRecallValueStrategy implements IStrategy { | ||
18 | - | ||
19 | - private int size; | ||
20 | - | ||
21 | - public CommonRecallValueStrategy(int size) { | ||
22 | - this.size = size; | ||
23 | - } | ||
24 | - | ||
25 | - @Override | ||
26 | - public StrategyEnum strategtEnum() { | ||
27 | - return StrategyEnum.COMMON_RECALL_VALUE; | ||
28 | - } | ||
29 | - | ||
30 | - @Override | ||
31 | - public QueryBuilder extendFilter() { | ||
32 | - return ExtendFilterHelper.commonRecallValueFilter(); | ||
33 | - } | ||
34 | - | ||
35 | - @Override | ||
36 | - public SortBuilder<?> sortBuilder() { | ||
37 | - return SortBuilderHelper.getRandomSort(); | ||
38 | - } | ||
39 | - | ||
40 | - @Override | ||
41 | - public int size() { | ||
42 | - return size; | ||
43 | - } | ||
44 | - | ||
45 | - @Override | ||
46 | - public int cacheTimeInMinute() { | ||
47 | - return CacheTimeConstants.COMMON_RECALL_STRATEGY_CACHE_TIME; | ||
48 | - } | ||
49 | - | ||
50 | - @Override | ||
51 | - public String strategyCacheKey() { | ||
52 | - StringBuilder sb = defaultStrategyKey(); | ||
53 | - return sb.toString(); | ||
54 | - } | ||
55 | - | ||
56 | -} |
service/src/main/java/com/yoho/search/recall/scene/beans/strategy/impls/CommonStrategy.java
deleted
100644 → 0
1 | -package com.yoho.search.recall.scene.beans.strategy.impls; | ||
2 | - | ||
3 | -import com.yoho.search.recall.scene.beans.helper.ExtendFilterHelper; | ||
4 | -import com.yoho.search.recall.scene.beans.helper.SortBuilderHelper; | ||
5 | -import com.yoho.search.recall.scene.beans.strategy.IStrategy; | ||
6 | -import com.yoho.search.recall.scene.beans.strategy.StrategyEnum; | ||
7 | -import com.yoho.search.recall.scene.constants.CacheTimeConstants; | ||
8 | -import org.elasticsearch.index.query.QueryBuilder; | ||
9 | -import org.elasticsearch.search.sort.SortBuilder; | ||
10 | - | ||
11 | -/** | ||
12 | - * 真正兜底的召回 | ||
13 | - * | ||
14 | - * @author gufei.hu | ||
15 | - * | ||
16 | - */ | ||
17 | -public class CommonStrategy implements IStrategy { | ||
18 | - | ||
19 | - private int size; | ||
20 | - | ||
21 | - public CommonStrategy(int size) { | ||
22 | - this.size = size; | ||
23 | - } | ||
24 | - | ||
25 | - @Override | ||
26 | - public StrategyEnum strategtEnum() { | ||
27 | - return StrategyEnum.COMMON; | ||
28 | - } | ||
29 | - | ||
30 | - @Override | ||
31 | - public QueryBuilder extendFilter() { | ||
32 | - return ExtendFilterHelper.commonFilter(); | ||
33 | - } | ||
34 | - | ||
35 | - @Override | ||
36 | - public SortBuilder<?> sortBuilder() { | ||
37 | - return SortBuilderHelper.getHeatValueDescSort(); | ||
38 | - } | ||
39 | - | ||
40 | - @Override | ||
41 | - public int size() { | ||
42 | - return size; | ||
43 | - } | ||
44 | - | ||
45 | - @Override | ||
46 | - public int cacheTimeInMinute() { | ||
47 | - return CacheTimeConstants.COMMON_RECALL_STRATEGY_CACHE_TIME; | ||
48 | - } | ||
49 | - | ||
50 | - @Override | ||
51 | - public String strategyCacheKey() { | ||
52 | - StringBuilder sb = defaultStrategyKey(); | ||
53 | - return sb.toString(); | ||
54 | - } | ||
55 | - | ||
56 | -} |
-
Please register or login to post a comment