Showing
5 changed files
with
56 additions
and
86 deletions
@@ -4,15 +4,12 @@ import com.yoho.core.config.ConfigReader; | @@ -4,15 +4,12 @@ import com.yoho.core.config.ConfigReader; | ||
4 | import com.yoho.search.aop.downgrade.PersionalRateLimit; | 4 | import com.yoho.search.aop.downgrade.PersionalRateLimit; |
5 | import com.yoho.search.aop.downgrade.PersionalRateLimitConfig; | 5 | import com.yoho.search.aop.downgrade.PersionalRateLimitConfig; |
6 | import com.yoho.search.base.utils.ConvertUtils; | 6 | import com.yoho.search.base.utils.ConvertUtils; |
7 | -import org.apache.commons.lang3.StringUtils; | ||
8 | import org.slf4j.Logger; | 7 | import org.slf4j.Logger; |
9 | import org.slf4j.LoggerFactory; | 8 | import org.slf4j.LoggerFactory; |
10 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
11 | import org.springframework.stereotype.Service; | 10 | import org.springframework.stereotype.Service; |
12 | 11 | ||
13 | -import javax.annotation.PostConstruct; | ||
14 | import java.util.ArrayList; | 12 | import java.util.ArrayList; |
15 | -import java.util.Arrays; | ||
16 | import java.util.List; | 13 | import java.util.List; |
17 | 14 | ||
18 | @Service | 15 | @Service |
@@ -23,36 +20,6 @@ public class SearchDynamicConfigService { | @@ -23,36 +20,6 @@ public class SearchDynamicConfigService { | ||
23 | @Autowired | 20 | @Autowired |
24 | private ConfigReader configReader; | 21 | private ConfigReader configReader; |
25 | 22 | ||
26 | - private List<String> ufoWholeFirstSearchKeyWords = new ArrayList<>(); | ||
27 | - private List<String> ufoPartFirstSearchKeyWords = new ArrayList<>(); | ||
28 | - | ||
29 | - @PostConstruct | ||
30 | - void init(){ | ||
31 | - | ||
32 | - //完全匹配 | ||
33 | - ufoWholeFirstSearchKeyWords.addAll(Arrays.asList("喷")); | ||
34 | - ufoPartFirstSearchKeyWords.addAll(Arrays.asList("冠军")); | ||
35 | - ufoPartFirstSearchKeyWords.addAll(Arrays.asList("椰子","yeezy")); | ||
36 | - | ||
37 | - //部分包含 | ||
38 | - ufoPartFirstSearchKeyWords.addAll(Arrays.asList("nike","耐克")); | ||
39 | - ufoPartFirstSearchKeyWords.addAll(Arrays.asList("adidas","originals","三叶草","阿迪","阿迪达斯")); | ||
40 | - ufoPartFirstSearchKeyWords.addAll(Arrays.asList("ow","off-white")); | ||
41 | - ufoPartFirstSearchKeyWords.addAll(Arrays.asList("亚限","欧限","美限")); | ||
42 | - ufoPartFirstSearchKeyWords.addAll(Arrays.asList("太极","飞马","倒勾","湖人","黑粉")); | ||
43 | - ufoPartFirstSearchKeyWords.addAll(Arrays.asList("aj", "air","max","force","pg","m2k","gs","supreme","af1")); | ||
44 | - ufoPartFirstSearchKeyWords.addAll(Arrays.asList("90","95","97","98","720","350", "500", "700")); | ||
45 | - | ||
46 | - //20190828新增 | ||
47 | - ufoPartFirstSearchKeyWords.addAll(Arrays.asList("满天星","詹姆斯","天使","哈登","蜘蛛侠","宝可梦","丝绸","亚洲","鸳鸯","阴阳")); | ||
48 | - ufoPartFirstSearchKeyWords.addAll(Arrays.asList("芝加哥","小闪电","子弹","sb","小花","蓝蛇","字母哥","小黑金","欧洲","凯尔特人")); | ||
49 | - ufoPartFirstSearchKeyWords.addAll(Arrays.asList("白斑马","万花筒","黑曜石","上海","union","芝麻","禁止","宇航员","四色鸳鸯","银子弹")); | ||
50 | - ufoPartFirstSearchKeyWords.addAll(Arrays.asList("彩虹","阿甘","遛狗","解构","鸽子","闪电","子弹头","灯芯绒","黑武士","艾弗森")); | ||
51 | - ufoPartFirstSearchKeyWords.addAll(Arrays.asList("钢铁侠","pg1","龙虾","首尔","笑脸","白冰淇淋","万圣节","海军蓝","冰淇淋","大理石")); | ||
52 | - ufoPartFirstSearchKeyWords.addAll(Arrays.asList("独角兽","大巴黎","做旧","af","要疯","黑魂","小麦","迈阿密限定","荔枝纹","绑带")); | ||
53 | - ufoPartFirstSearchKeyWords.addAll(Arrays.asList("熊猫","迷宫","马毛","骑士","纯白","黑曜石","慈善","透视骨骼","夜光骨头")); | ||
54 | - } | ||
55 | - | ||
56 | /** | 23 | /** |
57 | * 是否开启个性化 | 24 | * 是否开启个性化 |
58 | */ | 25 | */ |
@@ -240,25 +207,6 @@ public class SearchDynamicConfigService { | @@ -240,25 +207,6 @@ public class SearchDynamicConfigService { | ||
240 | } | 207 | } |
241 | 208 | ||
242 | /** | 209 | /** |
243 | - * ufo商品在前面的特殊搜索词 | ||
244 | - */ | ||
245 | - public boolean ufoProductFirstBySearchKeyWord(String query) { | ||
246 | - if(StringUtils.isBlank(query)){ | ||
247 | - return false; | ||
248 | - } | ||
249 | - String queryLowerCase = query.toLowerCase(); | ||
250 | - if(this.ufoWholeFirstSearchKeyWords.contains(queryLowerCase)){ | ||
251 | - return true; | ||
252 | - } | ||
253 | - for(String ufoPartFirstSearchKeyWord:this.ufoPartFirstSearchKeyWords){ | ||
254 | - if(queryLowerCase.contains(ufoPartFirstSearchKeyWord)){ | ||
255 | - return true; | ||
256 | - } | ||
257 | - } | ||
258 | - return false; | ||
259 | - } | ||
260 | - | ||
261 | - /** | ||
262 | * 新品天数 | 210 | * 新品天数 |
263 | */ | 211 | */ |
264 | public int newProductDayCount() { | 212 | public int newProductDayCount() { |
@@ -277,4 +225,12 @@ public class SearchDynamicConfigService { | @@ -277,4 +225,12 @@ public class SearchDynamicConfigService { | ||
277 | } | 225 | } |
278 | } | 226 | } |
279 | 227 | ||
228 | + public boolean sortSearchResourceAUserOpen() { | ||
229 | + return configReader.getBoolean("search.sort.resource.a.open", true); | ||
230 | + } | ||
231 | + | ||
232 | + public boolean sortSearchResourceBUserOpen() { | ||
233 | + return configReader.getBoolean("search.sort.resource.b.open", false); | ||
234 | + } | ||
235 | + | ||
280 | } | 236 | } |
1 | package com.yoho.search.common.utils; | 1 | package com.yoho.search.common.utils; |
2 | 2 | ||
3 | import com.yoho.search.common.SearchDynamicConfigService; | 3 | import com.yoho.search.common.SearchDynamicConfigService; |
4 | +import org.apache.commons.collections.MapUtils; | ||
4 | import org.apache.commons.lang.StringUtils; | 5 | import org.apache.commons.lang.StringUtils; |
6 | +import org.slf4j.Logger; | ||
7 | +import org.slf4j.LoggerFactory; | ||
5 | import org.springframework.beans.factory.annotation.Autowired; | 8 | import org.springframework.beans.factory.annotation.Autowired; |
6 | import org.springframework.stereotype.Component; | 9 | import org.springframework.stereotype.Component; |
7 | 10 | ||
8 | import java.util.List; | 11 | import java.util.List; |
12 | +import java.util.Map; | ||
9 | 13 | ||
10 | @Component | 14 | @Component |
11 | public class ABUserPartitionUtils { | 15 | public class ABUserPartitionUtils { |
12 | 16 | ||
17 | + private static final Logger logger = LoggerFactory.getLogger(ABUserPartitionUtils.class); | ||
18 | + | ||
13 | @Autowired | 19 | @Autowired |
14 | private SearchDynamicConfigService searchDynamicConfigService; | 20 | private SearchDynamicConfigService searchDynamicConfigService; |
15 | 21 | ||
16 | - private boolean isAUser(String udid) { | ||
17 | - if (StringUtils.isBlank(udid)) { | ||
18 | - return false; | ||
19 | - } | ||
20 | - List<String> aStrategyUdIds = searchDynamicConfigService.aStrategyUdIds(); | ||
21 | - if (aStrategyUdIds.contains(udid)) { | 22 | + public boolean isAUserComplete(int uid, String udid) { |
23 | + try { | ||
24 | + List<Integer> aStrategyUIds = searchDynamicConfigService.aStrategyUIds(); | ||
25 | + if (aStrategyUIds.contains(uid)) { | ||
26 | + return true; | ||
27 | + } | ||
28 | + if (StringUtils.isBlank(udid)) { | ||
29 | + return false; | ||
30 | + } | ||
31 | + List<String> aStrategyUdIds = searchDynamicConfigService.aStrategyUdIds(); | ||
32 | + if (aStrategyUdIds.contains(udid)) { | ||
33 | + return true; | ||
34 | + } | ||
35 | + int tail = Math.abs(udid.hashCode() % 1024); | ||
36 | + int aUserPercent = searchDynamicConfigService.partAUserPercent(); | ||
37 | + int aUserFloor = 1024 * aUserPercent / 100; | ||
38 | + return tail < aUserFloor ? true : false; | ||
39 | + } catch (Exception e) { | ||
40 | + logger.error(e.getMessage(), e); | ||
22 | return true; | 41 | return true; |
23 | } | 42 | } |
24 | - int tail = Math.abs(udid.hashCode() % 1024); | ||
25 | - int aUserPercent = searchDynamicConfigService.partAUserPercent(); | ||
26 | - int aUserFloor = 1024 * aUserPercent / 100; | ||
27 | - return tail < aUserFloor ? true : false; | ||
28 | } | 43 | } |
29 | 44 | ||
30 | - public boolean isAUserComplete(int uid, String udid) { | ||
31 | - List<Integer> aStrategyUIds = searchDynamicConfigService.aStrategyUIds(); | ||
32 | - if (aStrategyUIds.contains(uid)) { | ||
33 | - return true; | ||
34 | - } | ||
35 | - return isAUser(udid); | 45 | + public boolean isAUserComplete(Map<String, String> paramMap) { |
46 | + int uid = MapUtils.getIntValue(paramMap, "uid", 0); | ||
47 | + String udid = MapUtils.getString(paramMap, "udid", ""); | ||
48 | + return isAUserComplete(uid, udid); | ||
36 | } | 49 | } |
37 | 50 | ||
38 | public static void main(String[] args) { | 51 | public static void main(String[] args) { |
39 | // System.out.println(isAUserComplete(13420925, "f6ec847d5ac7ce275992db526666e997eb39425a"));//A版本 | 52 | // System.out.println(isAUserComplete(13420925, "f6ec847d5ac7ce275992db526666e997eb39425a"));//A版本 |
40 | // System.out.println(isAUserComplete(13420925, "00bcfa1e5d7745ad8c4188929134da18f8485dbd"));//B版本 | 53 | // System.out.println(isAUserComplete(13420925, "00bcfa1e5d7745ad8c4188929134da18f8485dbd"));//B版本 |
41 | int aUserFloor = 1024 * 49 / 100; | 54 | int aUserFloor = 1024 * 49 / 100; |
42 | - System.out.println( aUserFloor); | 55 | + System.out.println(aUserFloor); |
43 | } | 56 | } |
44 | 57 | ||
45 | } | 58 | } |
@@ -3,6 +3,8 @@ package com.yoho.search.service.scene.general; | @@ -3,6 +3,8 @@ package com.yoho.search.service.scene.general; | ||
3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
4 | import com.yoho.search.base.utils.ConvertUtils; | 4 | import com.yoho.search.base.utils.ConvertUtils; |
5 | import com.yoho.search.base.utils.SearchCollectionUtils; | 5 | import com.yoho.search.base.utils.SearchCollectionUtils; |
6 | +import com.yoho.search.common.SearchDynamicConfigService; | ||
7 | +import com.yoho.search.common.utils.ABUserPartitionUtils; | ||
6 | import com.yoho.search.service.helper.SearchCommonHelper; | 8 | import com.yoho.search.service.helper.SearchCommonHelper; |
7 | import com.yoho.search.service.index.CsSearchResourceIndexBaseService; | 9 | import com.yoho.search.service.index.CsSearchResourceIndexBaseService; |
8 | import org.apache.commons.collections.MapUtils; | 10 | import org.apache.commons.collections.MapUtils; |
@@ -27,10 +29,24 @@ public class CsSearchResourceService { | @@ -27,10 +29,24 @@ public class CsSearchResourceService { | ||
27 | private CsSearchResourceIndexBaseService csSearchResourceIndexBaseService; | 29 | private CsSearchResourceIndexBaseService csSearchResourceIndexBaseService; |
28 | @Autowired | 30 | @Autowired |
29 | private SearchCommonHelper searchCommonHelper; | 31 | private SearchCommonHelper searchCommonHelper; |
32 | + @Autowired | ||
33 | + private ABUserPartitionUtils abUserPartitionUtils; | ||
34 | + @Autowired | ||
35 | + private SearchDynamicConfigService searchDynamicConfigService; | ||
30 | 36 | ||
31 | //处理品类页的资源位直通车 | 37 | //处理品类页的资源位直通车 |
32 | public List<Map<String, Object>> querySortSearchResource(JSONObject productListData, Map<String, String> paramMap) { | 38 | public List<Map<String, Object>> querySortSearchResource(JSONObject productListData, Map<String, String> paramMap) { |
33 | try { | 39 | try { |
40 | + //0、判断是否开启 | ||
41 | + if(abUserPartitionUtils.isAUserComplete(paramMap)){ | ||
42 | + if(!searchDynamicConfigService.sortSearchResourceAUserOpen()){ | ||
43 | + return new ArrayList<>(); | ||
44 | + } | ||
45 | + }else{ | ||
46 | + if(!searchDynamicConfigService.sortSearchResourceBUserOpen()){ | ||
47 | + return new ArrayList<>(); | ||
48 | + } | ||
49 | + } | ||
34 | //1、获取全部销售类型的数据 | 50 | //1、获取全部销售类型的数据 |
35 | List<Map<String, Object>> allValidResources = csSearchResourceIndexBaseService.querySalesCategoryCsSearchResource(); | 51 | List<Map<String, Object>> allValidResources = csSearchResourceIndexBaseService.querySalesCategoryCsSearchResource(); |
36 | 52 |
@@ -75,22 +75,6 @@ public class SearchScorerFactory { | @@ -75,22 +75,6 @@ public class SearchScorerFactory { | ||
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | - // 获取【UFO商品】的打分器 | ||
79 | - public IScorer getUfoProductSearch(Map<String, String> paramMap) { | ||
80 | - if (!searchCommonHelper.containUFO(paramMap)) { | ||
81 | - return null; | ||
82 | - } | ||
83 | - if (!searchCommonHelper.isFuzzySearchPageDefault(paramMap)) { | ||
84 | - return null; | ||
85 | - } | ||
86 | - String query = MapUtils.getString(paramMap, SearchRequestParams.PARAM_SEARCH_QUERY, ""); | ||
87 | - if (dynamicConfig.ufoProductFirstBySearchKeyWord(query)) { | ||
88 | - return new UfoProductScorer(20f); | ||
89 | - } else { | ||
90 | - return null; | ||
91 | - } | ||
92 | - } | ||
93 | - | ||
94 | // // 获取【断码商品】的打分器 | 78 | // // 获取【断码商品】的打分器 |
95 | // public IScorer getBreakSizeProductScorer(Map<String, String> paramMap) { | 79 | // public IScorer getBreakSizeProductScorer(Map<String, String> paramMap) { |
96 | // try { | 80 | // try { |
@@ -75,5 +75,6 @@ search.agg.brand.product.new=true | @@ -75,5 +75,6 @@ search.agg.brand.product.new=true | ||
75 | search.productlist.return.goods=true | 75 | search.productlist.return.goods=true |
76 | search.ufo.contain.yoho=true | 76 | search.ufo.contain.yoho=true |
77 | search.newProduct.dayCount=7 | 77 | search.newProduct.dayCount=7 |
78 | -search.ufo.productName.prefixType=b | ||
79 | search.ufo.forbidden.entrace.brandIds= | 78 | search.ufo.forbidden.entrace.brandIds= |
79 | +search.sort.resource.a.open=true | ||
80 | +search.sort.resource.b.open=false |
-
Please register or login to post a comment