Merge branch 'master' into wn_promotion
Conflicts: service/src/main/java/com/yoho/search/recall/scene/beans/cache/BatchRecallCacheBean.java service/src/main/java/com/yoho/search/recall/scene/beans/cache/SknBaseInfoCacheBean.java service/src/main/java/com/yoho/search/recall/scene/beans/persional/AbstractPageComponent.java service/src/main/java/com/yoho/search/recall/scene/beans/persional/PageProductIdBitSetComponent.java service/src/main/java/com/yoho/search/recall/scene/models/personal/PageProductIdBitSet.java service/src/main/java/com/yoho/search/recall/scene/models/req/SknBaseInfoRequest.java service/src/main/java/com/yoho/search/recall/scene/models/req/SknBaseInfoResponse.java
Showing
13 changed files
with
91 additions
and
61 deletions
@@ -25,8 +25,8 @@ public class CommonRecallRequestBuilder{ | @@ -25,8 +25,8 @@ public class CommonRecallRequestBuilder{ | ||
25 | List<RecallRequest> requests = new ArrayList<>(); | 25 | List<RecallRequest> requests = new ArrayList<>(); |
26 | //1.1) firstSkn的召回 | 26 | //1.1) firstSkn的召回 |
27 | requests.add(this.buildFirstSknRequest(paramQueryFilter, firstProductSkns, SknCountConstants.FIRST_SKN)); | 27 | requests.add(this.buildFirstSknRequest(paramQueryFilter, firstProductSkns, SknCountConstants.FIRST_SKN)); |
28 | - //1.2) 直通车的召回 | ||
29 | - requests.add(this.buildDirectTrainRequest(paramQueryFilter, SknCountConstants.DIRECT_TRAIN)); | 28 | + //1.2) 直通车召回 |
29 | + requests.add(this.buildDirectTrainRequest(paramQueryFilter, SknCountConstants.DIRECT_TRAIN_RECALL_COUNT)); | ||
30 | //1.3) 人气的召回 | 30 | //1.3) 人气的召回 |
31 | requests.add(this.buildCommonRequest(paramQueryFilter,SknCountConstants.COMMON_HEAT_VALUE)); | 31 | requests.add(this.buildCommonRequest(paramQueryFilter,SknCountConstants.COMMON_HEAT_VALUE)); |
32 | //1.4) 新开店铺的召回 | 32 | //1.4) 新开店铺的召回 |
@@ -86,6 +86,7 @@ public class RecallMergerResultBuilder { | @@ -86,6 +86,7 @@ public class RecallMergerResultBuilder { | ||
86 | List<StrategyEnum> strategyEnumList = skn2StrategyListMap.getOrDefault(sknResult.getProductSkn(), new ArrayList<>()); | 86 | List<StrategyEnum> strategyEnumList = skn2StrategyListMap.getOrDefault(sknResult.getProductSkn(), new ArrayList<>()); |
87 | Collections.sort(strategyEnumList, (o1, o2) -> o2.getPriority().compareTo(o1.getPriority())); | 87 | Collections.sort(strategyEnumList, (o1, o2) -> o2.getPriority().compareTo(o1.getPriority())); |
88 | sknResult.setStrategy(strategyEnumList.get(0));//取优先级最高的召回策略 | 88 | sknResult.setStrategy(strategyEnumList.get(0));//取优先级最高的召回策略 |
89 | + sknResult.setOnlyOneStrategy(strategyEnumList.size()==1?true:false); | ||
89 | } | 90 | } |
90 | return sknResults; | 91 | return sknResults; |
91 | } | 92 | } |
@@ -168,7 +168,7 @@ public class UserRecallResponseBuilder { | @@ -168,7 +168,7 @@ public class UserRecallResponseBuilder { | ||
168 | PersonalizedSearch personalizedSearch = personalVectorFeatureSearch.getPersonalizedSearch(paramMap); | 168 | PersonalizedSearch personalizedSearch = personalVectorFeatureSearch.getPersonalizedSearch(paramMap); |
169 | UserFeatureFactor userFeatureFactor = new UserFeatureFactor(personalizedSearch); | 169 | UserFeatureFactor userFeatureFactor = new UserFeatureFactor(personalizedSearch); |
170 | //2、计算相关性 | 170 | //2、计算相关性 |
171 | - int recommendSknIndex = 1000; | 171 | + int recommendSknIndex = 10000; |
172 | for (RecallMergerResult.SknResult sknResult : sknResultList) { | 172 | for (RecallMergerResult.SknResult sknResult : sknResultList) { |
173 | double score = 0d; | 173 | double score = 0d; |
174 | //1)策略判断 | 174 | //1)策略判断 |
@@ -184,13 +184,20 @@ public class UserRecallResponseBuilder { | @@ -184,13 +184,20 @@ public class UserRecallResponseBuilder { | ||
184 | } | 184 | } |
185 | //3)向量计算 | 185 | //3)向量计算 |
186 | score = productFeatureFactorHepler.calProductFeatureFactor(userFeatureFactor, sknResult.getFactor()); | 186 | score = productFeatureFactorHepler.calProductFeatureFactor(userFeatureFactor, sknResult.getFactor()); |
187 | - //4)如果满足品类价格带偏好,则加分 | 187 | + |
188 | + //4)如果是直通车商品,则拿人气和向量综合评分 | ||
189 | + if (strategy.equals(StrategyEnum.DIRECT_TRAIN)) { | ||
190 | + score = score * sknResult.getHeatValue(); | ||
191 | + } | ||
192 | + | ||
193 | + //5)如果满足品类价格带偏好,则加分 | ||
188 | if (sknResult.isLikePriceArea()) { | 194 | if (sknResult.isLikePriceArea()) { |
189 | - score = score + 100; | 195 | + score = score + 1000; |
190 | } | 196 | } |
191 | - //5)如果兜底策略不参与评分,并且当前skn不是兜底召回的,则加分【将兜底和非兜底的拆分】 | 197 | + |
198 | + //6)如果兜底策略不参与评分,并且当前skn不是兜底召回的,则加分【将兜底和非兜底的拆分】 | ||
192 | if (!searchDynamicConfigService.searchPersionalNewStrategyCommonJoinScoreOpen() && !strategy.equals(StrategyEnum.COMMON)) { | 199 | if (!searchDynamicConfigService.searchPersionalNewStrategyCommonJoinScoreOpen() && !strategy.equals(StrategyEnum.COMMON)) { |
193 | - score = score + 50; | 200 | + score = score + 500; |
194 | } | 201 | } |
195 | sknResult.setScore(score); | 202 | sknResult.setScore(score); |
196 | } | 203 | } |
@@ -250,16 +257,26 @@ public class UserRecallResponseBuilder { | @@ -250,16 +257,26 @@ public class UserRecallResponseBuilder { | ||
250 | } | 257 | } |
251 | 258 | ||
252 | // 3、插入【直接推荐】的商品-随机插入 | 259 | // 3、插入【直接推荐】的商品-随机插入 |
253 | - this.addByIndexIndex(sknResultList, results, 1, 2, (sknResult -> StrategyEnum.RECOMMEND_SKN.equals(sknResult.getStrategy()))); | 260 | + this.addByIndexIndex(sknResultList, results, 1, 2, (sknResult -> StrategyEnum.RECOMMEND_SKN.equals(sknResult.getStrategy())),dropTransfer); |
254 | 261 | ||
255 | - // 4、插入【直通车】商品 | 262 | + // 4、插入【直通车】商品-随机插入 |
256 | int directTrainIndexInterval = searchDynamicConfigService.directTrainIndexInterval(); | 263 | int directTrainIndexInterval = searchDynamicConfigService.directTrainIndexInterval(); |
257 | - this.addByIndexIndex(sknResultList, results, 4, directTrainIndexInterval, (sknResult -> StrategyEnum.DIRECT_TRAIN.equals(sknResult.getStrategy()))); | 264 | + this.addByIndexIndex(sknResultList, results, 4, directTrainIndexInterval, (sknResult -> StrategyEnum.DIRECT_TRAIN.equals(sknResult.getStrategy())),dropTransfer); |
258 | 265 | ||
259 | return results; | 266 | return results; |
260 | } | 267 | } |
261 | 268 | ||
262 | - private static <T> void addByIndexIndex(List<T> fromList, List<T> toList,int fromIndex, int indexInterval,Transfer<T, Boolean> match) { | 269 | + /** |
270 | + * 单策略召回时,超出数量直接丢弃 | ||
271 | + */ | ||
272 | + private static Transfer<RecallMergerResult.SknResult,Boolean> dropTransfer = new Transfer<RecallMergerResult.SknResult, Boolean>() { | ||
273 | + @Override | ||
274 | + public Boolean transfer(RecallMergerResult.SknResult sknResult) { | ||
275 | + return sknResult.isOnlyOneStrategy()?true:false; | ||
276 | + } | ||
277 | + }; | ||
278 | + | ||
279 | + private static <T> void addByIndexIndex(List<T> fromList, List<T> toList,int fromIndex, int indexInterval,Transfer<T, Boolean> match,Transfer<T, Boolean> drop) { | ||
263 | Iterator<T> iterator = fromList.iterator(); | 280 | Iterator<T> iterator = fromList.iterator(); |
264 | while (iterator.hasNext()) { | 281 | while (iterator.hasNext()) { |
265 | T object = iterator.next(); | 282 | T object = iterator.next(); |
@@ -268,15 +285,14 @@ public class UserRecallResponseBuilder { | @@ -268,15 +285,14 @@ public class UserRecallResponseBuilder { | ||
268 | } | 285 | } |
269 | // 生成插入位置 | 286 | // 生成插入位置 |
270 | int toListNewSize = toList.size(); | 287 | int toListNewSize = toList.size(); |
271 | - System.out.println(fromIndex); | ||
272 | // 尽量不影响第1个 | 288 | // 尽量不影响第1个 |
273 | if (fromIndex == 0 && !toList.isEmpty()) { | 289 | if (fromIndex == 0 && !toList.isEmpty()) { |
274 | fromIndex = 1; | 290 | fromIndex = 1; |
275 | } | 291 | } |
276 | - //超出新列表的长度,则加到最后面 | 292 | + //超出新列表的长度,判断是否直接丢弃 |
277 | if (fromIndex <= toListNewSize) { | 293 | if (fromIndex <= toListNewSize) { |
278 | toList.add(fromIndex, object); | 294 | toList.add(fromIndex, object); |
279 | - }else{ | 295 | + }else if(drop !=null && !drop.transfer(object)){ |
280 | toList.add(object); | 296 | toList.add(object); |
281 | } | 297 | } |
282 | iterator.remove(); | 298 | iterator.remove(); |
@@ -296,10 +312,10 @@ public class UserRecallResponseBuilder { | @@ -296,10 +312,10 @@ public class UserRecallResponseBuilder { | ||
296 | } | 312 | } |
297 | 313 | ||
298 | List<Integer> toList = new ArrayList<>(); | 314 | List<Integer> toList = new ArrayList<>(); |
299 | - for (int index =0;index <100;index ++){ | 315 | + for (int index =0;index <1;index ++){ |
300 | toList.add(0); | 316 | toList.add(0); |
301 | } | 317 | } |
302 | - addByIndexIndex(fromList, toList, 1, 2, (value -> value%2==1)); | 318 | + addByIndexIndex(fromList, toList, 1, 2, (value -> value%2==1),null); |
303 | System.out.println(toList); | 319 | System.out.println(toList); |
304 | // addByIndexIndex(fromList, toList, 4, 4, (value -> value%2==0)); | 320 | // addByIndexIndex(fromList, toList, 4, 4, (value -> value%2==0)); |
305 | // System.out.println(toList); | 321 | // System.out.println(toList); |
@@ -38,7 +38,7 @@ public class BatchRecallCacheBean extends AbstractCacheBean<RecallRequest,Recall | @@ -38,7 +38,7 @@ public class BatchRecallCacheBean extends AbstractCacheBean<RecallRequest,Recall | ||
38 | results.add(new RecallRequestResponse(request)); | 38 | results.add(new RecallRequestResponse(request)); |
39 | } | 39 | } |
40 | //2、执行查询 | 40 | //2、执行查询 |
41 | - this.bacthFillResponseWithCache(results,10); | 41 | + this.bacthFillResponseWithCache(results,15); |
42 | //3、返回结果 | 42 | //3、返回结果 |
43 | return results; | 43 | return results; |
44 | } | 44 | } |
@@ -123,8 +123,9 @@ public class SknBaseInfoCacheBean extends AbstractCacheBean<SknBaseInfoRequest, | @@ -123,8 +123,9 @@ public class SknBaseInfoCacheBean extends AbstractCacheBean<SknBaseInfoRequest, | ||
123 | Integer middleSortId = MapUtils.getInteger(productInfo, ProductIndexEsField.middleSortId, 0); | 123 | Integer middleSortId = MapUtils.getInteger(productInfo, ProductIndexEsField.middleSortId, 0); |
124 | Integer priceArea = MapUtils.getInteger(productInfo, ProductIndexEsField.priceArea, 0); | 124 | Integer priceArea = MapUtils.getInteger(productInfo, ProductIndexEsField.priceArea, 0); |
125 | String productFeatureFactor = MapUtils.getString(productInfo, ProductIndexEsField.productFeatureFactor, ""); | 125 | String productFeatureFactor = MapUtils.getString(productInfo, ProductIndexEsField.productFeatureFactor, ""); |
126 | + Integer heatValue = MapUtils.getInteger(productInfo, ProductIndexEsField.heatValue, 0); | ||
126 | 127 | ||
127 | - SknBaseInfoResponse sknBaseInfo = new SknBaseInfoResponse(productId, productSkn, brandId, middleSortId, priceArea, productFeatureFactor); | 128 | + SknBaseInfoResponse sknBaseInfo = new SknBaseInfoResponse(productId, productSkn, brandId, middleSortId, priceArea, productFeatureFactor,heatValue); |
128 | productTempMap.put(productSkn, sknBaseInfo); | 129 | productTempMap.put(productSkn, sknBaseInfo); |
129 | } | 130 | } |
130 | //5、构造最终结果-有可能是null的 | 131 | //5、构造最终结果-有可能是null的 |
@@ -54,8 +54,6 @@ public class SknRecallCacheBean { | @@ -54,8 +54,6 @@ public class SknRecallCacheBean { | ||
54 | try { | 54 | try { |
55 | if (recommedSknList == null || recommedSknList.isEmpty()) { | 55 | if (recommedSknList == null || recommedSknList.isEmpty()) { |
56 | return new ArrayList<>(); | 56 | return new ArrayList<>(); |
57 | - //localhost:8080/yohosearch/productindex/productList.json?uid=11145&status=1&gender=1,2,3,4,5 | ||
58 | - //recommedSknList = Arrays.asList(50020667,50026235,50026280,50024584,50026611,50028826,50031356,50031387,50029959,51001108); | ||
59 | } | 57 | } |
60 | List<Integer> filterSknList; | 58 | List<Integer> filterSknList; |
61 | if (recallWithCache) { | 59 | if (recallWithCache) { |
@@ -63,15 +61,17 @@ public class SknRecallCacheBean { | @@ -63,15 +61,17 @@ public class SknRecallCacheBean { | ||
63 | } else { | 61 | } else { |
64 | filterSknList = this.filterRecommedSknListByEs(userRecallRequest, recommedSknList); | 62 | filterSknList = this.filterRecommedSknListByEs(userRecallRequest, recommedSknList); |
65 | } | 63 | } |
64 | + RECALL_NEW_LOGGER.info("recommedSknList size is [{}], filterSknListSize is[{}]", recommedSknList.size(), filterSknList.size()); | ||
66 | return this.buildResults(userRecallRequest, filterSknList, maxReturnCount); | 65 | return this.buildResults(userRecallRequest, filterSknList, maxReturnCount); |
67 | - }catch (Exception e){ | ||
68 | - RECALL_NEW_LOGGER.error(e.getMessage(),e); | 66 | + } catch (Exception e) { |
67 | + RECALL_NEW_LOGGER.error(e.getMessage(), e); | ||
69 | return new ArrayList<>(); | 68 | return new ArrayList<>(); |
70 | } | 69 | } |
71 | } | 70 | } |
72 | 71 | ||
73 | /** | 72 | /** |
74 | * 从ehcahc或者redis中构造返回结果 | 73 | * 从ehcahc或者redis中构造返回结果 |
74 | + * | ||
75 | * @param userRecallRequest | 75 | * @param userRecallRequest |
76 | * @param recommedSknList | 76 | * @param recommedSknList |
77 | * @return | 77 | * @return |
@@ -79,7 +79,7 @@ public class SknRecallCacheBean { | @@ -79,7 +79,7 @@ public class SknRecallCacheBean { | ||
79 | private List<Integer> filterRecommendWithCache(UserRecallRequest userRecallRequest, List<Integer> recommedSknList) { | 79 | private List<Integer> filterRecommendWithCache(UserRecallRequest userRecallRequest, List<Integer> recommedSknList) { |
80 | //1、skn转成productId | 80 | //1、skn转成productId |
81 | Map<Integer, Integer> productSknToIdMap = sknBaseInfoCacheBean.queryProductSknToProductIdMap(recommedSknList); | 81 | Map<Integer, Integer> productSknToIdMap = sknBaseInfoCacheBean.queryProductSknToProductIdMap(recommedSknList); |
82 | - if(productSknToIdMap==null || productSknToIdMap.isEmpty()){ | 82 | + if (productSknToIdMap == null || productSknToIdMap.isEmpty()) { |
83 | return new ArrayList<>(); | 83 | return new ArrayList<>(); |
84 | } | 84 | } |
85 | List<Integer> recommedProductIds = new ArrayList<>(); | 85 | List<Integer> recommedProductIds = new ArrayList<>(); |
@@ -88,29 +88,26 @@ public class SknRecallCacheBean { | @@ -88,29 +88,26 @@ public class SknRecallCacheBean { | ||
88 | //2、先从本地缓存获取 | 88 | //2、先从本地缓存获取 |
89 | ParamQueryFilter paramQueryFilter = userRecallRequest.getParamQueryFilter(); | 89 | ParamQueryFilter paramQueryFilter = userRecallRequest.getParamQueryFilter(); |
90 | RedisKeyBuilder redisKeyBuilder = pageProductIdBitSetComponent.genRedisKeyBuilder(paramQueryFilter); | 90 | RedisKeyBuilder redisKeyBuilder = pageProductIdBitSetComponent.genRedisKeyBuilder(paramQueryFilter); |
91 | - Map<Integer, Boolean> ehcacheQueryResult = ehCache.getFromBitSet(redisKeyBuilder,recommedProductIds); | 91 | + Map<Integer, Boolean> ehcacheQueryResult = ehCache.getFromBitSet(redisKeyBuilder, recommedProductIds); |
92 | if (ehcacheQueryResult != null) { | 92 | if (ehcacheQueryResult != null) { |
93 | - return this.filterSknByCacheQueryResult(recommedSknList,productSknToIdMap, ehcacheQueryResult); | 93 | + RECALL_NEW_LOGGER.info("filterSknBy EhCache success"); |
94 | + return this.filterSknByCacheQueryResult(recommedSknList, productSknToIdMap, ehcacheQueryResult); | ||
94 | } | 95 | } |
95 | - | ||
96 | //3、再从redis的bitset缓存结构中过滤 | 96 | //3、再从redis的bitset缓存结构中过滤 |
97 | Map<Integer, Boolean> redisQueryResult = searchRedis.getFromBitSet(redisKeyBuilder, recommedProductIds); | 97 | Map<Integer, Boolean> redisQueryResult = searchRedis.getFromBitSet(redisKeyBuilder, recommedProductIds); |
98 | if (redisQueryResult != null) { | 98 | if (redisQueryResult != null) { |
99 | - //TODO 回写本地缓存 | ||
100 | - return this.filterSknByCacheQueryResult(recommedSknList, productSknToIdMap,redisQueryResult); | 99 | + RECALL_NEW_LOGGER.info("filterSknBy Redis success"); |
100 | + return this.filterSknByCacheQueryResult(recommedSknList, productSknToIdMap, redisQueryResult); | ||
101 | } | 101 | } |
102 | - | ||
103 | //4、执行查询,添加到缓存 | 102 | //4、执行查询,添加到缓存 |
104 | PageProductIdBitSet pageProductIdBitSet = pageProductIdBitSetComponent.queryPageProductIdBitSet(userRecallRequest.getParamQueryFilter()); | 103 | PageProductIdBitSet pageProductIdBitSet = pageProductIdBitSetComponent.queryPageProductIdBitSet(userRecallRequest.getParamQueryFilter()); |
105 | - //3.1)添加到本地缓存 | ||
106 | - this.ehCache.setBitSet(redisKeyBuilder,pageProductIdBitSet.getProductIdBitSet(),pageProductIdBitSetComponent.cacheTimeInMinute()); | ||
107 | - //3.2)添加到redis缓存 | ||
108 | - //TODO 异步加入redis缓存 | ||
109 | - this.searchRedis.setBitSet(redisKeyBuilder,pageProductIdBitSet.getProductIdBitSet(),pageProductIdBitSetComponent.cacheTimeInMinute()); | ||
110 | - return this.filterSknByPageProductIdBitSet(recommedSknList,productSknToIdMap, pageProductIdBitSet.getProductIdBitSet()); | 104 | + //4.1)添加到本地缓存 |
105 | + this.ehCache.setBitSet(redisKeyBuilder, pageProductIdBitSet.getProductIdBitSet(), pageProductIdBitSetComponent.cacheTimeInMinute()); | ||
106 | + //4.2)异步添加到redis缓存 | ||
107 | + this.searchRedis.setBitSet(redisKeyBuilder, pageProductIdBitSet.getProductIdBitSet(), pageProductIdBitSetComponent.cacheTimeInMinute()); | ||
108 | + return this.filterSknByPageProductIdBitSet(recommedSknList, productSknToIdMap, pageProductIdBitSet.getProductIdBitSet()); | ||
111 | } | 109 | } |
112 | 110 | ||
113 | - | ||
114 | /** | 111 | /** |
115 | * 从bitset对象中构造返回对象 | 112 | * 从bitset对象中构造返回对象 |
116 | * | 113 | * |
@@ -118,11 +115,11 @@ public class SknRecallCacheBean { | @@ -118,11 +115,11 @@ public class SknRecallCacheBean { | ||
118 | * @param bitSet | 115 | * @param bitSet |
119 | * @return | 116 | * @return |
120 | */ | 117 | */ |
121 | - private List<Integer> filterSknByPageProductIdBitSet(List<Integer> recommedSknList,Map<Integer, Integer> productSknToIdMap, BitSet bitSet) { | 118 | + private List<Integer> filterSknByPageProductIdBitSet(List<Integer> recommedSknList, Map<Integer, Integer> productSknToIdMap, BitSet bitSet) { |
122 | List<Integer> existProductSkns = new ArrayList<>(); | 119 | List<Integer> existProductSkns = new ArrayList<>(); |
123 | for (Integer recommedSkn : recommedSknList) { | 120 | for (Integer recommedSkn : recommedSknList) { |
124 | Integer productId = productSknToIdMap.get(recommedSkn); | 121 | Integer productId = productSknToIdMap.get(recommedSkn); |
125 | - if(productId==null){ | 122 | + if (productId == null) { |
126 | continue; | 123 | continue; |
127 | } | 124 | } |
128 | if (!bitSet.get(productId)) { | 125 | if (!bitSet.get(productId)) { |
@@ -140,11 +137,11 @@ public class SknRecallCacheBean { | @@ -140,11 +137,11 @@ public class SknRecallCacheBean { | ||
140 | * @param cacheQueryResult | 137 | * @param cacheQueryResult |
141 | * @return | 138 | * @return |
142 | */ | 139 | */ |
143 | - private List<Integer> filterSknByCacheQueryResult(List<Integer> recommedSknList,Map<Integer, Integer> productSknToIdMap, Map<Integer, Boolean> cacheQueryResult) { | 140 | + private List<Integer> filterSknByCacheQueryResult(List<Integer> recommedSknList, Map<Integer, Integer> productSknToIdMap, Map<Integer, Boolean> cacheQueryResult) { |
144 | List<Integer> existProductSkns = new ArrayList<>(); | 141 | List<Integer> existProductSkns = new ArrayList<>(); |
145 | for (Integer recommedSkn : recommedSknList) { | 142 | for (Integer recommedSkn : recommedSknList) { |
146 | Integer productId = productSknToIdMap.get(recommedSkn); | 143 | Integer productId = productSknToIdMap.get(recommedSkn); |
147 | - if(productId==null){ | 144 | + if (productId == null) { |
148 | continue; | 145 | continue; |
149 | } | 146 | } |
150 | if (!cacheQueryResult.getOrDefault(productId, false)) { | 147 | if (!cacheQueryResult.getOrDefault(productId, false)) { |
@@ -28,7 +28,7 @@ public abstract class AbstractPageComponent<T> { | @@ -28,7 +28,7 @@ public abstract class AbstractPageComponent<T> { | ||
28 | private ConcurrentHashMap<String, Integer> mapLock; | 28 | private ConcurrentHashMap<String, Integer> mapLock; |
29 | private ExecutorService executorService; | 29 | private ExecutorService executorService; |
30 | 30 | ||
31 | - private boolean synchronous = true;//是否同步 | 31 | + private boolean synchronous = false;//是否同步 |
32 | 32 | ||
33 | @PostConstruct | 33 | @PostConstruct |
34 | void init() { | 34 | void init() { |
service/src/main/java/com/yoho/search/recall/scene/beans/persional/PageProductIdBitSetComponent.java
@@ -59,14 +59,15 @@ public class PageProductIdBitSetComponent extends AbstractPageComponent<PageProd | @@ -59,14 +59,15 @@ public class PageProductIdBitSetComponent extends AbstractPageComponent<PageProd | ||
59 | 59 | ||
60 | BoolQueryBuilder filter = QueryBuilders.boolQuery(); | 60 | BoolQueryBuilder filter = QueryBuilders.boolQuery(); |
61 | filter.must(paramQueryFilter.getParamFilter()); | 61 | filter.must(paramQueryFilter.getParamFilter()); |
62 | - filter.mustNot(ExtendFilterHelper.notRecallFilter());//聚合的时候带上不召回的数据 | 62 | + //filter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.isGlobal, "Y")); |
63 | + //filter.mustNot(QueryBuilders.rangeQuery(ProductIndexEsField.breakSizePercent).gt(50)); | ||
63 | searchParam.setFiter(filter); | 64 | searchParam.setFiter(filter); |
64 | 65 | ||
65 | searchParam.setSize(0); | 66 | searchParam.setSize(0); |
66 | 67 | ||
67 | //2、构造聚合参数 | 68 | //2、构造聚合参数 |
68 | List<AbstractAggregationBuilder<?>> aggregationBuilders = new ArrayList<>(); | 69 | List<AbstractAggregationBuilder<?>> aggregationBuilders = new ArrayList<>(); |
69 | - aggregationBuilders.add(AggregationBuilders.terms("productIdAgg").field(ProductIndexEsField.productId).size(100000).order(Terms.Order.term(false)));//品类-品牌聚合 | 70 | + aggregationBuilders.add(AggregationBuilders.terms("productIdAgg").field(ProductIndexEsField.productId).size(100000).order(Terms.Order.term(false))); |
70 | searchParam.setAggregationBuilders(aggregationBuilders); | 71 | searchParam.setAggregationBuilders(aggregationBuilders); |
71 | 72 | ||
72 | //3、执行查询 | 73 | //3、执行查询 |
@@ -8,7 +8,9 @@ public class SknCountConstants { | @@ -8,7 +8,9 @@ public class SknCountConstants { | ||
8 | public static final int COMMON_HEAT_VALUE = 60; | 8 | public static final int COMMON_HEAT_VALUE = 60; |
9 | 9 | ||
10 | public static final int FIRST_SKN = 1; | 10 | public static final int FIRST_SKN = 1; |
11 | - public static final int DIRECT_TRAIN = 20; | 11 | + public static final int DIRECT_TRAIN_RECALL_COUNT = 100; |
12 | + public static final int DIRECT_TRAIN_RETURN_COUNT = 20; | ||
13 | + | ||
12 | public static final int NEW_SHOP = 10; | 14 | public static final int NEW_SHOP = 10; |
13 | public static final int ADD_FLOW = 10; | 15 | public static final int ADD_FLOW = 10; |
14 | 16 |
@@ -35,10 +35,12 @@ public class RecallMergerResult { | @@ -35,10 +35,12 @@ public class RecallMergerResult { | ||
35 | private Integer brandId; | 35 | private Integer brandId; |
36 | private Integer middleSortId; | 36 | private Integer middleSortId; |
37 | private Integer priceArea; | 37 | private Integer priceArea; |
38 | + private Integer heatValue; | ||
38 | private String factor; | 39 | private String factor; |
39 | 40 | ||
40 | private Double score; | 41 | private Double score; |
41 | private boolean likePriceArea; | 42 | private boolean likePriceArea; |
43 | + private boolean onlyOneStrategy; | ||
42 | 44 | ||
43 | public SknResult(Integer productSkn) { | 45 | public SknResult(Integer productSkn) { |
44 | this.productSkn = productSkn; | 46 | this.productSkn = productSkn; |
@@ -50,6 +52,7 @@ public class RecallMergerResult { | @@ -50,6 +52,7 @@ public class RecallMergerResult { | ||
50 | this.brandId = sknBaseInfoResponse.getBrandId(); | 52 | this.brandId = sknBaseInfoResponse.getBrandId(); |
51 | this.middleSortId = sknBaseInfoResponse.getMisortId(); | 53 | this.middleSortId = sknBaseInfoResponse.getMisortId(); |
52 | this.priceArea = sknBaseInfoResponse.getPriceArea(); | 54 | this.priceArea = sknBaseInfoResponse.getPriceArea(); |
55 | + this.heatValue = sknBaseInfoResponse.getHeatValue(); | ||
53 | this.factor = sknBaseInfoResponse.getProductFeatureFactor(); | 56 | this.factor = sknBaseInfoResponse.getProductFeatureFactor(); |
54 | } | 57 | } |
55 | 58 | ||
@@ -57,6 +60,10 @@ public class RecallMergerResult { | @@ -57,6 +60,10 @@ public class RecallMergerResult { | ||
57 | this.strategy = strategy; | 60 | this.strategy = strategy; |
58 | } | 61 | } |
59 | 62 | ||
63 | + public void setOnlyOneStrategy(boolean onlyOneStrategy) { | ||
64 | + this.onlyOneStrategy = onlyOneStrategy; | ||
65 | + } | ||
66 | + | ||
60 | public void setScore(Double score) { | 67 | public void setScore(Double score) { |
61 | this.score = score; | 68 | this.score = score; |
62 | } | 69 | } |
@@ -98,6 +105,13 @@ public class RecallMergerResult { | @@ -98,6 +105,13 @@ public class RecallMergerResult { | ||
98 | return likePriceArea; | 105 | return likePriceArea; |
99 | } | 106 | } |
100 | 107 | ||
108 | + public Integer getHeatValue() { | ||
109 | + return heatValue; | ||
110 | + } | ||
111 | + | ||
112 | + public boolean isOnlyOneStrategy() { | ||
113 | + return onlyOneStrategy; | ||
114 | + } | ||
101 | } | 115 | } |
102 | 116 | ||
103 | } | 117 | } |
@@ -21,19 +21,8 @@ public class PageProductIdBitSet implements Serializable{ | @@ -21,19 +21,8 @@ public class PageProductIdBitSet implements Serializable{ | ||
21 | this.productIdBitSet.set(bitSetIndex); | 21 | this.productIdBitSet.set(bitSetIndex); |
22 | } | 22 | } |
23 | 23 | ||
24 | - public boolean exist(int bitSetIndex) { | ||
25 | - return productIdBitSet.get(bitSetIndex); | ||
26 | - } | ||
27 | - | ||
28 | - public int getCardinality(){ | ||
29 | - return productIdBitSet.cardinality(); | ||
30 | - } | ||
31 | - | ||
32 | public BitSet getProductIdBitSet() { | 24 | public BitSet getProductIdBitSet() { |
33 | return productIdBitSet; | 25 | return productIdBitSet; |
34 | } | 26 | } |
35 | 27 | ||
36 | - public void setProductIdBitSet(BitSet productIdBitSet) { | ||
37 | - this.productIdBitSet = productIdBitSet; | ||
38 | - } | ||
39 | } | 28 | } |
@@ -5,11 +5,14 @@ import com.yoho.search.base.utils.ProductIndexEsField; | @@ -5,11 +5,14 @@ import com.yoho.search.base.utils.ProductIndexEsField; | ||
5 | import com.yoho.search.recall.scene.constants.CacheTimeConstants; | 5 | import com.yoho.search.recall.scene.constants.CacheTimeConstants; |
6 | import com.yoho.search.recall.scene.models.common.ICacheRequest; | 6 | import com.yoho.search.recall.scene.models.common.ICacheRequest; |
7 | 7 | ||
8 | +import java.util.ArrayList; | ||
8 | import java.util.Arrays; | 9 | import java.util.Arrays; |
9 | import java.util.List; | 10 | import java.util.List; |
10 | 11 | ||
11 | public class SknBaseInfoRequest implements ICacheRequest{ | 12 | public class SknBaseInfoRequest implements ICacheRequest{ |
12 | 13 | ||
14 | + private static final List<String> includeFields = Arrays.asList(ProductIndexEsField.productId,ProductIndexEsField.productSkn,ProductIndexEsField.brandId,ProductIndexEsField.middleSortId,ProductIndexEsField.priceArea,ProductIndexEsField.productFeatureFactor,ProductIndexEsField.heatValue); | ||
15 | + | ||
13 | private Integer productSkn; | 16 | private Integer productSkn; |
14 | 17 | ||
15 | public SknBaseInfoRequest(Integer productSkn){ | 18 | public SknBaseInfoRequest(Integer productSkn){ |
@@ -30,12 +33,8 @@ public class SknBaseInfoRequest implements ICacheRequest{ | @@ -30,12 +33,8 @@ public class SknBaseInfoRequest implements ICacheRequest{ | ||
30 | return productSkn; | 33 | return productSkn; |
31 | } | 34 | } |
32 | 35 | ||
33 | - /** | ||
34 | - * 请求返回的字段 | ||
35 | - * @return | ||
36 | - */ | ||
37 | public List<String> includeFields(){ | 36 | public List<String> includeFields(){ |
38 | - return Arrays.asList(ProductIndexEsField.productId,ProductIndexEsField.productSkn,ProductIndexEsField.brandId,ProductIndexEsField.middleSortId,ProductIndexEsField.priceArea,ProductIndexEsField.productFeatureFactor); | 37 | + return includeFields; |
39 | } | 38 | } |
40 | 39 | ||
41 | } | 40 | } |
@@ -12,18 +12,20 @@ public class SknBaseInfoResponse implements Serializable{ | @@ -12,18 +12,20 @@ public class SknBaseInfoResponse implements Serializable{ | ||
12 | private Integer misortId; | 12 | private Integer misortId; |
13 | private Integer priceArea; | 13 | private Integer priceArea; |
14 | private String productFeatureFactor; | 14 | private String productFeatureFactor; |
15 | + private Integer heatValue; | ||
15 | 16 | ||
16 | public SknBaseInfoResponse() { | 17 | public SknBaseInfoResponse() { |
17 | 18 | ||
18 | } | 19 | } |
19 | 20 | ||
20 | - public SknBaseInfoResponse(Integer productId, Integer productSkn, Integer brandId, Integer misortId, Integer priceArea, String productFeatureFactor) { | 21 | + public SknBaseInfoResponse(Integer productId, Integer productSkn, Integer brandId, Integer misortId, Integer priceArea, String productFeatureFactor,Integer heatValue) { |
21 | this.productId = productId; | 22 | this.productId = productId; |
22 | this.productSkn = productSkn; | 23 | this.productSkn = productSkn; |
23 | this.brandId = brandId; | 24 | this.brandId = brandId; |
24 | this.misortId = misortId; | 25 | this.misortId = misortId; |
25 | this.priceArea = priceArea; | 26 | this.priceArea = priceArea; |
26 | this.productFeatureFactor = productFeatureFactor; | 27 | this.productFeatureFactor = productFeatureFactor; |
28 | + this.heatValue = heatValue; | ||
27 | } | 29 | } |
28 | 30 | ||
29 | public Integer getProductSkn() { | 31 | public Integer getProductSkn() { |
@@ -73,4 +75,12 @@ public class SknBaseInfoResponse implements Serializable{ | @@ -73,4 +75,12 @@ public class SknBaseInfoResponse implements Serializable{ | ||
73 | public void setProductFeatureFactor(String productFeatureFactor) { | 75 | public void setProductFeatureFactor(String productFeatureFactor) { |
74 | this.productFeatureFactor = productFeatureFactor; | 76 | this.productFeatureFactor = productFeatureFactor; |
75 | } | 77 | } |
78 | + | ||
79 | + public Integer getHeatValue() { | ||
80 | + return heatValue; | ||
81 | + } | ||
82 | + | ||
83 | + public void setHeatValue(Integer heatValue) { | ||
84 | + this.heatValue = heatValue; | ||
85 | + } | ||
76 | } | 86 | } |
-
Please register or login to post a comment