Authored by hugufei

Merge branch 'master' into new_list

... ... @@ -39,6 +39,7 @@ import com.yoho.search.recall.sort.strategy.NewPromotionStrategy;
import com.yoho.search.recall.sort.strategy.NewReducePriceStrategy;
import com.yoho.search.recall.sort.strategy.NewShelveStrategy;
import com.yoho.search.recall.sort.strategy.NewShopStrategy;
import sun.applet.Main;
@Service
public class SortRecallSceneService extends AbstractRecallService {
... ... @@ -103,7 +104,7 @@ public class SortRecallSceneService extends AbstractRecallService {
// 1、支持firstProductSkn的召回
recallStrategy.add(new FirstProductSknStrategy(1, recallServiceHelper.getFirstProductSkns(paramMap)));
// 2、支持直通车的召回-随机召回
recallStrategy.add(new DirectTrainStrategy(2));
recallStrategy.add(new DirectTrainStrategy(20));
// 3、支持曝光补偿的召回-大数据给的,随机召回
recallStrategy.add(new AddFlowStrategy(2));
// 4、新开店铺商品召回-随机召回
... ... @@ -207,17 +208,16 @@ public class SortRecallSceneService extends AbstractRecallService {
iterator = productList.iterator();
int index = 0;
while (iterator.hasNext()) {
// 生成插入位置
Map<String, Object> product = iterator.next();
// 生成插入位置-超出新列表的长度,则直接丢弃
int totalNewProductListSize = newProductList.size();
int randomIndex = (int) (4 * (index++ + Math.random()));
if (randomIndex > totalNewProductListSize) {
randomIndex = totalNewProductListSize;
}
if (randomIndex == 0 && !newProductList.isEmpty()) {
randomIndex = 1;
randomIndex = 1;//防止影响firstSkn
}
Map<String, Object> product = iterator.next();
if(randomIndex <= totalNewProductListSize){
newProductList.add(randomIndex, product);
}
iterator.remove();
}
// 4、数量截取-保留整数页个商品[只能召回一页,则保留一页]
... ... @@ -235,4 +235,37 @@ public class SortRecallSceneService extends AbstractRecallService {
return recallResult;
}
public static void main(String[] args) {
List<Integer> aList = new ArrayList<Integer>();
for (int i=0;i<100;i++){
aList.add(0);
}
List<Integer> bList = new ArrayList<Integer>();
for (int i=0;i<30;i++){
bList.add(1);
}
int index = 0;
int insertCount = 0;
Iterator<Integer> iterator = bList.iterator();
while (iterator.hasNext()) {
Integer bValue = iterator.next();
// 生成插入位置-超出列表长度,直接丢弃
int totalNewProductListSize = aList.size();
int randomIndex = (int) (4 * (index++ + Math.random()));
if (randomIndex == 0 && !aList.isEmpty()) {
randomIndex = 1;//防止影响firstSkn
}
System.out.println(randomIndex);
if(randomIndex <= totalNewProductListSize){
aList.add(randomIndex, bValue);
insertCount++;
}
iterator.remove();
}
System.out.println(aList);
System.out.println(insertCount);
System.out.println(aList.size());
}
}
... ...
... ... @@ -43,7 +43,6 @@ public class DirectTrainStrategy implements IRecallStrategy {
@Override
public QueryBuilder filter() {
BoolQueryBuilder filter = QueryBuilders.boolQuery();
filter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.flowType, "2"));
filter.must(QueryBuilders.termQuery(ProductIndexEsField.toAddScore, "Y"));
return filter;
}
... ...