Authored by hugufei

各召回策略打散

... ... @@ -134,6 +134,7 @@ public class SortRecallSceneService extends AbstractRecallService {
// 3)填充变价计划,并做品牌打散
begin = System.currentTimeMillis();
List<Map<String, Object>> product_list = productIndexBaseService.getProductListWithPricePlan(recallProductInfoList.getProductInfoList());
product_list = productListSortService.sortProductList(product_list, paramMap);
super.doLogInfo("[func8=getProductListWithPricePlan][cost={}ms]", System.currentTimeMillis() - begin);
// 4)构造返回结果
... ... @@ -316,7 +317,7 @@ public class SortRecallSceneService extends AbstractRecallService {
// 3、设置order
searchParam.setSortBuilders(Arrays.asList(SortBuilders.scoreSort().order(SortOrder.DESC)));
searchParam.setOffset(0);
searchParam.setSize(30);
searchParam.setSize(20);
// 4、从缓存中获取
JSONArray brandIdJSONArray = searchCacheService.getJSONArrayFromCache(recallSearchCache, ISearchConstants.INDEX_NAME_BRAND, searchParam);
... ... @@ -412,14 +413,24 @@ public class SortRecallSceneService extends AbstractRecallService {
@Override
protected RecallResult doCarefulRank(Map<String, String> paramMap, RecallResult recallResult) {
List<Map<String, Object>> results = new ArrayList<Map<String, Object>>();
// 1、获取productList
List<Map<String, Object>> productList = recallResult.getProductList();
// 2、精排
Collections.shuffle(productList);
// 3、TODO 品牌打散
// 2、各召回策略随机打散【除兜底的】
Iterator<Map<String, Object>> iterator = productList.iterator();
while (iterator.hasNext()) {
Map<String, Object> product = iterator.next();
if (!product.get("recallType").equals(RecallType.COMMON)) {
results.add(product);
iterator.remove();
}
}
Collections.shuffle(results);
// 3、加入剩余商品
results.addAll(productList);
// 4、回设productList
recallResult.setProductList(productList);
recallResult.setProductList(results);
return recallResult;
}
... ...