Authored by unknown

召回支持新开店铺以及过滤促销类型

... ... @@ -57,6 +57,7 @@ import com.yoho.search.service.scene.recall.strategy.IRecallStrategy;
import com.yoho.search.service.scene.recall.strategy.NewPromotionStrategy;
import com.yoho.search.service.scene.recall.strategy.NewReducePriceStrategy;
import com.yoho.search.service.scene.recall.strategy.NewShelveStrategy;
import com.yoho.search.service.scene.recall.strategy.NewShopStrategy;
import com.yoho.search.service.scene.recall.type.RecallType;
import com.yoho.search.service.service.IProductIndexService;
... ... @@ -130,7 +131,8 @@ 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);
// product_list =
// productListSortService.sortProductList(product_list, paramMap);
logger.warn("[func2=getProductListWithPricePlan][cost={}]", System.currentTimeMillis() - begin);
// 4)构造返回结果
... ... @@ -256,7 +258,7 @@ public class SortRecallSceneService extends AbstractRecallService {
String uid = MapUtils.getString(paramMap, "uid", "0");
String vectorFeatureVersion = searchDynamicConfigService.personalizedSearchVersion();
String userGlobalBrandIds = bigDataRedisService.getUserGlobalFaveriteBrand(uid, vectorFeatureVersion);
logger.warn("uid is [{}],vectorFeatureVersion is [{}], userGlobalBrandIds is [{}]",uid,vectorFeatureVersion,userGlobalBrandIds);
logger.warn("uid is [{}],vectorFeatureVersion is [{}], userGlobalBrandIds is [{}]", uid, vectorFeatureVersion, userGlobalBrandIds);
JSONArray brandJsonArray = JSON.parseArray(userGlobalBrandIds);
List<Integer> results = new ArrayList<Integer>();
for (int i = 0; i < brandJsonArray.size(); i++) {
... ... @@ -347,19 +349,21 @@ public class SortRecallSceneService extends AbstractRecallService {
List<IRecallStrategy> recallStrategy = new ArrayList<IRecallStrategy>();
int pageSize = this.getPageSize(paramMap);
// 0、获取用户偏好品牌
//List<Integer> brandIds = this.getUserGlobalBrandIds(paramMap);
// List<Integer> brandIds = this.getUserGlobalBrandIds(paramMap);
List<Integer> brandIds = this.getUserLikeBrandIds(paramMap);
// 1、支持firstProductSkn的召回
recallStrategy.add(new FirstProductSknStrategy(1, this.getFirstProductSkns(paramMap)));
// 2、支持直通车的召回
// 2、支持直通车的召回-随机召回
recallStrategy.add(new DirectTrainStrategy(2));
// 3、支持曝光补偿的召回
// 3、支持曝光补偿的召回-大数据给的,随机召回
recallStrategy.add(new AddFlowStrategy(2));
// 4、支持新上架的召回
// 4、新开店铺商品召回-随机召回
recallStrategy.add(new NewShopStrategy(2));
// 5、支持新上架的召回-有new标签的
recallStrategy.add(new NewShelveStrategy(brandIds, 10));
// 5、支持新降价的召回
// 6、支持新降价的召回-两天内实际降过价的
recallStrategy.add(new NewReducePriceStrategy(brandIds, 10));
// 6、支持新开促销的召回
// 7、支持新开促销的召回-5种促销类型
recallStrategy.add(new NewPromotionStrategy(brandIds, 10));
// 8、支持兜底的召回-人气排序
recallStrategy.add(new CommonStrategy(pageSize));
... ...
package com.yoho.search.service.scene.recall.strategy;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
... ... @@ -36,6 +37,7 @@ public class NewPromotionStrategy implements IRecallStrategy {
long hourFirstTime = DateUtil.getHourFirstTimeSecond(new Date());
nestedFilter.must(QueryBuilders.rangeQuery(ProductIndexEsField.matchedPromotionsStartTime).lt(hourFirstTime));
nestedFilter.must(QueryBuilders.rangeQuery(ProductIndexEsField.matchedPromotionsEndTime).gte(hourFirstTime));
nestedFilter.must(QueryBuilders.termsQuery(ProductIndexEsField.matchedPromotionsType, Arrays.asList("Cashreduce","Cheapestfree","Degressdiscount","Discount","SpecifiedAmount")));
}
@Override
... ...
package com.yoho.search.service.scene.recall.strategy;
import java.util.Date;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.script.Script;
import org.elasticsearch.search.sort.ScriptSortBuilder.ScriptSortType;
import org.elasticsearch.search.sort.SortBuilder;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
import com.yoho.search.base.utils.DateUtil;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.service.scene.recall.type.RecallType;
public class NewShopStrategy implements IRecallStrategy {
private int size;
public NewShopStrategy(int size) {
this.size = size;
}
@Override
public RecallType recallType() {
return RecallType.NEW_SHOP;
}
@Override
public int size() {
return this.size;
}
@Override
public QueryBuilder filter() {
BoolQueryBuilder filter = QueryBuilders.boolQuery();
filter.mustNot(QueryBuilders.termQuery(ProductIndexEsField.flowType, "2"));
filter.must(QueryBuilders.rangeQuery(ProductIndexEsField.shopCreateTime).gte(DateUtil.getFirstTimeSecond(DateUtil.addDay(new Date(), -3))));
return filter;
}
@Override
public SortBuilder<?> firstSortBuilder() {
return SortBuilders.scriptSort(new Script("Math.random()"), ScriptSortType.NUMBER).order(SortOrder.ASC);
}
}
... ...
... ... @@ -7,9 +7,9 @@ public enum RecallType {
NEW_SHELVE,//新上架
NEW_REDUCE_PRICE,//新降价
NEW_PROMOTION,//新开促销
NEW_SHOP,//新开店铺
ADD_FLOW,//曝光补偿
PERSIONAL,//个性化
COMMON;//兜底策略
}
... ...