|
@@ -55,7 +55,7 @@ public class UserRecallResponseBuilder { |
|
@@ -55,7 +55,7 @@ public class UserRecallResponseBuilder { |
55
|
sknResultList = this.fillBaseInfo(sknResultList);
|
55
|
sknResultList = this.fillBaseInfo(sknResultList);
|
56
|
|
56
|
|
57
|
//4、填充是否满足品类价格带的过滤
|
57
|
//4、填充是否满足品类价格带的过滤
|
58
|
- sknResultList = this.fillIsLikePriceArea(sknResultList, userPersonalFactor);
|
58
|
+ sknResultList = this.fillIsLikePriceArea(userRecallRequest.getUid(),sknResultList, userPersonalFactor);
|
59
|
|
59
|
|
60
|
//5、按相关性计算得分
|
60
|
//5、按相关性计算得分
|
61
|
sknResultList = this.doCalScoreAndSort(sknResultList, userRecallRequest.getUid());
|
61
|
sknResultList = this.doCalScoreAndSort(sknResultList, userRecallRequest.getUid());
|
|
@@ -130,7 +130,7 @@ public class UserRecallResponseBuilder { |
|
@@ -130,7 +130,7 @@ public class UserRecallResponseBuilder { |
130
|
* @param sknResults
|
130
|
* @param sknResults
|
131
|
* @return
|
131
|
* @return
|
132
|
*/
|
132
|
*/
|
133
|
- private List<RecallMergerResult.SknResult> fillIsLikePriceArea(List<RecallMergerResult.SknResult> sknResults, UserPersonalFactor userPersonalFactor) {
|
133
|
+ private List<RecallMergerResult.SknResult> fillIsLikePriceArea(int uid, List<RecallMergerResult.SknResult> sknResults, UserPersonalFactor userPersonalFactor) {
|
134
|
//1、获取用户价格带偏好
|
134
|
//1、获取用户价格带偏好
|
135
|
List<SortPriceAreas> userSortPriceAreasList = userPersonalFactor.getSortPriceAreasList();
|
135
|
List<SortPriceAreas> userSortPriceAreasList = userPersonalFactor.getSortPriceAreasList();
|
136
|
if (userSortPriceAreasList == null || userSortPriceAreasList.isEmpty()) {
|
136
|
if (userSortPriceAreasList == null || userSortPriceAreasList.isEmpty()) {
|
|
@@ -144,16 +144,67 @@ public class UserRecallResponseBuilder { |
|
@@ -144,16 +144,67 @@ public class UserRecallResponseBuilder { |
144
|
//3、填充当前skn是否属于用户偏好的价格带
|
144
|
//3、填充当前skn是否属于用户偏好的价格带
|
145
|
for (RecallMergerResult.SknResult sknResult : sknResults) {
|
145
|
for (RecallMergerResult.SknResult sknResult : sknResults) {
|
146
|
Integer misortId = sknResult.getMiddleSortId();
|
146
|
Integer misortId = sknResult.getMiddleSortId();
|
147
|
- List<Integer> priceAreas = userMisort2PriceAreasMap.getOrDefault(misortId, new ArrayList<>());
|
|
|
148
|
- if (priceAreas.contains(sknResult.getPriceArea())) {
|
|
|
149
|
- sknResult.setLikePriceArea(true);
|
|
|
150
|
- } else {
|
|
|
151
|
- sknResult.setLikePriceArea(false);
|
|
|
152
|
- }
|
147
|
+ List<Integer> userPriceAreas = userMisort2PriceAreasMap.getOrDefault(misortId, new ArrayList<>());
|
|
|
148
|
+ boolean isLikePriceArea = this.isLikePriceArea(uid,userPriceAreas,sknResult.getPriceArea());
|
|
|
149
|
+ sknResult.setLikePriceArea(isLikePriceArea);
|
153
|
}
|
150
|
}
|
154
|
return sknResults;
|
151
|
return sknResults;
|
155
|
}
|
152
|
}
|
156
|
|
153
|
|
|
|
154
|
+ /**
|
|
|
155
|
+ * AB test
|
|
|
156
|
+ * @param uid
|
|
|
157
|
+ * @param userPriceAreas
|
|
|
158
|
+ * @param sknPriceArea
|
|
|
159
|
+ * @return
|
|
|
160
|
+ */
|
|
|
161
|
+ private boolean isLikePriceArea(int uid, List<Integer> userPriceAreas,Integer sknPriceArea){
|
|
|
162
|
+ if(userPriceAreas==null || userPriceAreas.isEmpty()){
|
|
|
163
|
+ return false;
|
|
|
164
|
+ }
|
|
|
165
|
+ if(uid%2==1){
|
|
|
166
|
+ if(searchDynamicConfigService.isAStrategyOpen()){
|
|
|
167
|
+ return isLikePriceAreaWithAStrategy(userPriceAreas,sknPriceArea);
|
|
|
168
|
+ }else{
|
|
|
169
|
+ return isLikePriceAreaWithBStrategy(userPriceAreas,sknPriceArea);
|
|
|
170
|
+ }
|
|
|
171
|
+ }else{
|
|
|
172
|
+ if(searchDynamicConfigService.isBStrategyOpen()){
|
|
|
173
|
+ return isLikePriceAreaWithBStrategy(userPriceAreas,sknPriceArea);
|
|
|
174
|
+ }else{
|
|
|
175
|
+ return isLikePriceAreaWithAStrategy(userPriceAreas,sknPriceArea);
|
|
|
176
|
+ }
|
|
|
177
|
+ }
|
|
|
178
|
+ }
|
|
|
179
|
+
|
|
|
180
|
+ private boolean isLikePriceAreaWithAStrategy(List<Integer> userPriceAreas,Integer sknPriceArea){
|
|
|
181
|
+ return userPriceAreas.contains(sknPriceArea);
|
|
|
182
|
+ }
|
|
|
183
|
+
|
|
|
184
|
+ /**
|
|
|
185
|
+ * 价格带左右各扩展一位
|
|
|
186
|
+ * @param userPriceAreas
|
|
|
187
|
+ * @param sknPriceArea
|
|
|
188
|
+ * @return
|
|
|
189
|
+ */
|
|
|
190
|
+ private boolean isLikePriceAreaWithBStrategy(List<Integer> userPriceAreas,Integer sknPriceArea){
|
|
|
191
|
+ Collections.sort(userPriceAreas);
|
|
|
192
|
+ int min = userPriceAreas.get(0);
|
|
|
193
|
+ int max = userPriceAreas.get(userPriceAreas.size()-1);
|
|
|
194
|
+ int leftCount = min<=1 ? 0 : max>=7 ? 2 : 1;
|
|
|
195
|
+ int rightCount = min<=1 ? 2 : max>=7 ? 0 : 1;
|
|
|
196
|
+ for(int i = 1;i<=leftCount;i++){
|
|
|
197
|
+ if(min-i>=1){
|
|
|
198
|
+ userPriceAreas.add(0,min-i);
|
|
|
199
|
+ }
|
|
|
200
|
+ }
|
|
|
201
|
+ for(int i = 1;i<=rightCount;i++){
|
|
|
202
|
+ if(max+i<=7){
|
|
|
203
|
+ userPriceAreas.add(max+i);
|
|
|
204
|
+ }
|
|
|
205
|
+ }
|
|
|
206
|
+ return userPriceAreas.contains(sknPriceArea);
|
|
|
207
|
+ }
|
157
|
|
208
|
|
158
|
/**
|
209
|
/**
|
159
|
* 粗排-按相关性计算得分,并按得分排序
|
210
|
* 粗排-按相关性计算得分,并按得分排序
|
|
@@ -304,24 +355,24 @@ public class UserRecallResponseBuilder { |
|
@@ -304,24 +355,24 @@ public class UserRecallResponseBuilder { |
304
|
}
|
355
|
}
|
305
|
|
356
|
|
306
|
public static void main(String[] args) {
|
357
|
public static void main(String[] args) {
|
307
|
- List<Integer> fromList = new ArrayList<>();
|
|
|
308
|
- for (int index =1;index <=30;index ++){
|
|
|
309
|
- fromList.add(index);
|
358
|
+ List<Integer> userPriceAreas = new ArrayList<>();
|
|
|
359
|
+ userPriceAreas.addAll(Arrays.asList(5,6,7));
|
|
|
360
|
+ Collections.sort(userPriceAreas);
|
|
|
361
|
+ int min = userPriceAreas.get(0);
|
|
|
362
|
+ int max = userPriceAreas.get(userPriceAreas.size()-1);
|
|
|
363
|
+ int leftCount = min<=1 ? 0 : max>=7 ? 2 : 1;
|
|
|
364
|
+ int rightCount = min<=1 ? 2 : max>=7 ? 0 : 1;
|
|
|
365
|
+ for(int i = 1;i<=leftCount;i++){
|
|
|
366
|
+ if(min-i>=1){
|
|
|
367
|
+ userPriceAreas.add(0,min-i);
|
310
|
}
|
368
|
}
|
311
|
-
|
|
|
312
|
- List<Integer> toList = new ArrayList<>();
|
|
|
313
|
- for (int index =0;index <100;index ++){
|
|
|
314
|
- toList.add(0);
|
|
|
315
|
}
|
369
|
}
|
316
|
- addByIndexIndex(fromList, toList, 1, 2, (value -> value%2==1),null);
|
|
|
317
|
-
|
|
|
318
|
- addByIndexIndex(fromList, toList, 2, 3, (value -> value%2==0),null);
|
|
|
319
|
-
|
|
|
320
|
- System.out.println(toList);
|
|
|
321
|
-// addByIndexIndex(fromList, toList, 4, 4, (value -> value%2==0));
|
|
|
322
|
-// System.out.println(toList);
|
370
|
+ for(int i = 1;i<=rightCount;i++){
|
|
|
371
|
+ if(max+i<=7){
|
|
|
372
|
+ userPriceAreas.add(max+i);
|
|
|
373
|
+ }
|
|
|
374
|
+ }
|
|
|
375
|
+ System.out.println(userPriceAreas);
|
323
|
}
|
376
|
}
|
324
|
-
|
|
|
325
|
-
|
|
|
326
|
|
377
|
|
327
|
} |
378
|
} |