Authored by hugufei

Merge branch 'master' into new_list

@@ -39,6 +39,7 @@ import com.yoho.search.recall.sort.strategy.NewPromotionStrategy; @@ -39,6 +39,7 @@ import com.yoho.search.recall.sort.strategy.NewPromotionStrategy;
39 import com.yoho.search.recall.sort.strategy.NewReducePriceStrategy; 39 import com.yoho.search.recall.sort.strategy.NewReducePriceStrategy;
40 import com.yoho.search.recall.sort.strategy.NewShelveStrategy; 40 import com.yoho.search.recall.sort.strategy.NewShelveStrategy;
41 import com.yoho.search.recall.sort.strategy.NewShopStrategy; 41 import com.yoho.search.recall.sort.strategy.NewShopStrategy;
  42 +import sun.applet.Main;
42 43
43 @Service 44 @Service
44 public class SortRecallSceneService extends AbstractRecallService { 45 public class SortRecallSceneService extends AbstractRecallService {
@@ -103,7 +104,7 @@ public class SortRecallSceneService extends AbstractRecallService { @@ -103,7 +104,7 @@ public class SortRecallSceneService extends AbstractRecallService {
103 // 1、支持firstProductSkn的召回 104 // 1、支持firstProductSkn的召回
104 recallStrategy.add(new FirstProductSknStrategy(1, recallServiceHelper.getFirstProductSkns(paramMap))); 105 recallStrategy.add(new FirstProductSknStrategy(1, recallServiceHelper.getFirstProductSkns(paramMap)));
105 // 2、支持直通车的召回-随机召回 106 // 2、支持直通车的召回-随机召回
106 - recallStrategy.add(new DirectTrainStrategy(2)); 107 + recallStrategy.add(new DirectTrainStrategy(20));
107 // 3、支持曝光补偿的召回-大数据给的,随机召回 108 // 3、支持曝光补偿的召回-大数据给的,随机召回
108 recallStrategy.add(new AddFlowStrategy(2)); 109 recallStrategy.add(new AddFlowStrategy(2));
109 // 4、新开店铺商品召回-随机召回 110 // 4、新开店铺商品召回-随机召回
@@ -207,17 +208,16 @@ public class SortRecallSceneService extends AbstractRecallService { @@ -207,17 +208,16 @@ public class SortRecallSceneService extends AbstractRecallService {
207 iterator = productList.iterator(); 208 iterator = productList.iterator();
208 int index = 0; 209 int index = 0;
209 while (iterator.hasNext()) { 210 while (iterator.hasNext()) {
210 - // 生成插入位置 211 + Map<String, Object> product = iterator.next();
  212 + // 生成插入位置-超出新列表的长度,则直接丢弃
211 int totalNewProductListSize = newProductList.size(); 213 int totalNewProductListSize = newProductList.size();
212 int randomIndex = (int) (4 * (index++ + Math.random())); 214 int randomIndex = (int) (4 * (index++ + Math.random()));
213 - if (randomIndex > totalNewProductListSize) {  
214 - randomIndex = totalNewProductListSize;  
215 - }  
216 if (randomIndex == 0 && !newProductList.isEmpty()) { 215 if (randomIndex == 0 && !newProductList.isEmpty()) {
217 - randomIndex = 1; 216 + randomIndex = 1;//防止影响firstSkn
218 } 217 }
219 - Map<String, Object> product = iterator.next(); 218 + if(randomIndex <= totalNewProductListSize){
220 newProductList.add(randomIndex, product); 219 newProductList.add(randomIndex, product);
  220 + }
221 iterator.remove(); 221 iterator.remove();
222 } 222 }
223 // 4、数量截取-保留整数页个商品[只能召回一页,则保留一页] 223 // 4、数量截取-保留整数页个商品[只能召回一页,则保留一页]
@@ -235,4 +235,37 @@ public class SortRecallSceneService extends AbstractRecallService { @@ -235,4 +235,37 @@ public class SortRecallSceneService extends AbstractRecallService {
235 return recallResult; 235 return recallResult;
236 } 236 }
237 237
  238 + public static void main(String[] args) {
  239 + List<Integer> aList = new ArrayList<Integer>();
  240 + for (int i=0;i<100;i++){
  241 + aList.add(0);
  242 + }
  243 + List<Integer> bList = new ArrayList<Integer>();
  244 + for (int i=0;i<30;i++){
  245 + bList.add(1);
  246 + }
  247 +
  248 + int index = 0;
  249 + int insertCount = 0;
  250 + Iterator<Integer> iterator = bList.iterator();
  251 + while (iterator.hasNext()) {
  252 + Integer bValue = iterator.next();
  253 + // 生成插入位置-超出列表长度,直接丢弃
  254 + int totalNewProductListSize = aList.size();
  255 + int randomIndex = (int) (4 * (index++ + Math.random()));
  256 + if (randomIndex == 0 && !aList.isEmpty()) {
  257 + randomIndex = 1;//防止影响firstSkn
  258 + }
  259 + System.out.println(randomIndex);
  260 + if(randomIndex <= totalNewProductListSize){
  261 + aList.add(randomIndex, bValue);
  262 + insertCount++;
  263 + }
  264 + iterator.remove();
  265 + }
  266 + System.out.println(aList);
  267 + System.out.println(insertCount);
  268 + System.out.println(aList.size());
  269 + }
  270 +
238 } 271 }
@@ -43,7 +43,6 @@ public class DirectTrainStrategy implements IRecallStrategy { @@ -43,7 +43,6 @@ public class DirectTrainStrategy implements IRecallStrategy {
43 @Override 43 @Override
44 public QueryBuilder filter() { 44 public QueryBuilder filter() {
45 BoolQueryBuilder filter = QueryBuilders.boolQuery(); 45 BoolQueryBuilder filter = QueryBuilders.boolQuery();
46 - filter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.flowType, "2"));  
47 filter.must(QueryBuilders.termQuery(ProductIndexEsField.toAddScore, "Y")); 46 filter.must(QueryBuilders.termQuery(ProductIndexEsField.toAddScore, "Y"));
48 return filter; 47 return filter;
49 } 48 }