Authored by hugufei

品牌向量+品类向量开发

... ... @@ -28,8 +28,11 @@ public class SortBrandRecallRequestBuilder {
* @return
*/
public List<RecallRequest> buildSortBrandRecallRequests(int uid, ParamQueryFilter paramQueryFilter, List<SortBrand> sortBrands, SortBrandType sortBrandType, int recallSknCount) {
//1、构造召回请求
List<RecallRequest> requests = new ArrayList<>();
// 0)、参数判断
if(sortBrands==null || sortBrands.isEmpty()){
return requests;
}
// 1) 人气
for (SortBrand sortBrand : sortBrands) {
requests.add(this.buildSortBrandHeatValueRequest(paramQueryFilter, sortBrand, recallSknCount, sortBrandType));
... ...
package com.yoho.search.recall.scene.beans.cache;
import com.alibaba.fastjson.JSON;
import com.yoho.search.base.utils.CollectionUtils;
import com.yoho.search.core.personalized.models.SortBrand;
import com.yoho.search.models.SearchApiResult;
import com.yoho.search.recall.scene.beans.builder.*;
import com.yoho.search.recall.scene.beans.persional.QueryUserPersionalFactorBean;
import com.yoho.search.recall.scene.beans.strategy.SortBrandType;
import com.yoho.search.recall.scene.beans.strategy.impls.RecommendSknStrategy;
import com.yoho.search.recall.scene.constants.SknCountConstants;
import com.yoho.search.recall.scene.models.common.RecallMergerResult;
import com.yoho.search.recall.scene.models.personal.UserPersonalFactor;
import com.yoho.search.recall.scene.models.req.*;
import com.yoho.search.service.base.SearchDynamicConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -43,7 +38,7 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us
@Autowired
private UserRecallResponseBuilder userRecallResponseBuilder;
private ExecutorService recallExecutorService = Executors.newFixedThreadPool(30);
private ExecutorService recallExecutorService = Executors.newFixedThreadPool(50);
/**
* 召回入口
... ... @@ -105,7 +100,7 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us
private List<RecallRequestResponse> batchRecall(UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) {
//1、处理实时推荐SKN的召回
CompletableFuture<List<RecallRequestResponse>> recallBySknListCompletableFuture = this.doRecallBySknList(userRecallRequest, userPersonalFactor);
CompletableFuture<List<RecallRequestResponse>> sknListCompletableFuture = this.doRecallSknList(userRecallRequest, userPersonalFactor);
//2、处理通用召回
CompletableFuture<List<RecallRequestResponse>> commonCompletableFuture = this.doRecallCommon(userRecallRequest, userPersonalFactor);
... ... @@ -113,22 +108,26 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us
//3、处理实时推荐的品类品牌的召回
CompletableFuture<List<RecallRequestResponse>> realTimeSortBrandCompletableFuture = this.doRecallRealTimeSortBrand(userRecallRequest, userPersonalFactor);
//4、处理基于向量生成的品类品牌的召回
CompletableFuture<List<RecallRequestResponse>> vectorSortBrandCompletableFuture = this.doRecallVectorSortBrand(userRecallRequest, userPersonalFactor);
//5、处理RNN预测的品类品牌的召回
//4、处理预测的品类品牌的召回
CompletableFuture<List<RecallRequestResponse>> forecastSortBrandCompletableFuture = this.doRecallPredictSortBrand(userRecallRequest, userPersonalFactor);
//6、构造最终返回结果投入额
//5、处理基于RNN向量生成的品类品牌的召回
CompletableFuture<List<RecallRequestResponse>> vectorRnnSortBrandCompletableFuture = this.doRecallVectorRnnSortBrand(userRecallRequest, userPersonalFactor);
//7、处理基于W2V向量生成的品类品牌的召回
CompletableFuture<List<RecallRequestResponse>> vectorW2vSortBrandCompletableFuture = this.doRecallVectorW2vSortBrand(userRecallRequest, userPersonalFactor);
//8、构造最终返回结果投入额
List<RecallRequestResponse> batchRequestResults = new ArrayList<>();
batchRequestResults.addAll(this.getResultFromCompletableFuture(recallBySknListCompletableFuture));//按skn召回放在第一个,不然merger的时候可能会无序
batchRequestResults.addAll(this.getResultFromCompletableFuture(sknListCompletableFuture));//按skn召回放在第一个,不然merger的时候可能会无序
batchRequestResults.addAll(this.getResultFromCompletableFuture(commonCompletableFuture));
batchRequestResults.addAll(this.getResultFromCompletableFuture(realTimeSortBrandCompletableFuture));
batchRequestResults.addAll(this.getResultFromCompletableFuture(vectorSortBrandCompletableFuture));
batchRequestResults.addAll(this.getResultFromCompletableFuture(forecastSortBrandCompletableFuture));
batchRequestResults.addAll(this.getResultFromCompletableFuture(vectorRnnSortBrandCompletableFuture));
batchRequestResults.addAll(this.getResultFromCompletableFuture(vectorW2vSortBrandCompletableFuture));
//6、日志打印
//9、日志打印
if (userRecallRequest.openDetailLog()) {
for (RecallRequestResponse recallRequestResponse : batchRequestResults) {
RecallRequest recallRequest = recallRequestResponse.getRequest();
... ... @@ -174,12 +173,11 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us
* @param userPersonalFactor
* @return
*/
private CompletableFuture<List<RecallRequestResponse>> doRecallBySknList(UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) {
private CompletableFuture<List<RecallRequestResponse>> doRecallSknList(UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) {
return CompletableFuture.supplyAsync(() -> {
long begin = System.currentTimeMillis();
int recommendSknCount = userPersonalFactor.getRecommendSknList() == null ? 0 : userPersonalFactor.getRecommendSknList().size();
List<RecallRequestResponse> recommendSknRequestResponses = sknRecallCacheBean.batchRecallBySknList(userRecallRequest, userPersonalFactor, SknCountConstants.REC_SKN_COUNT);
RECALL_NEW_LOGGER.info("UserRecallCacheBean[2.2]-doRecallRecommendSkn,recommendSknCount is [{}],cost is [{}]", recommendSknCount, System.currentTimeMillis() - begin);
RECALL_NEW_LOGGER.info("UserRecallCacheBean[2.2]-doRecallRecommendSkn,recommendSknCount is [{}],cost is [{}]", recommendSknRequestResponses.size(), System.currentTimeMillis() - begin);
return recommendSknRequestResponses;
}, recallExecutorService);
}
... ... @@ -202,36 +200,54 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us
}
/**
* 执行向量【品牌+品类】的召回
* 执行预测【品牌+品类】的召回
*
* @param userRecallRequest
* @param userPersonalFactor
* @return
*/
private CompletableFuture<List<RecallRequestResponse>> doRecallPredictSortBrand(UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) {
return CompletableFuture.supplyAsync(() -> {
long begin = System.currentTimeMillis();
List<RecallRequest> forecastSortBrandRequests = sortBrandRecallRequestBuilder.buildSortBrandRecallRequests(userRecallRequest.getUid(), userRecallRequest.getParamQueryFilter(), userPersonalFactor.getPredictSortBrandList(), SortBrandType.PRED_SORT_BRAND, SknCountConstants.PRED_SORT_BRAND_SKN_COUNT);
List<RecallRequestResponse> forecastSortBrandRequestsResponses = batchRecallCacheBean.batchRecallAndCache(forecastSortBrandRequests);
RECALL_NEW_LOGGER.info("UserRecallCacheBean[2.4]-doRecallPredictSortBrand,requestCount is [{}], cost is [{}]", forecastSortBrandRequests.size(), System.currentTimeMillis() - begin);
return forecastSortBrandRequestsResponses;
}, recallExecutorService);
}
/**
* 执行RNN向量【品牌+品类】的召回
*
* @param userRecallRequest
* @param userPersonalFactor
* @return
*/
private CompletableFuture<List<RecallRequestResponse>> doRecallVectorSortBrand(UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) {
private CompletableFuture<List<RecallRequestResponse>> doRecallVectorRnnSortBrand(UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) {
return CompletableFuture.supplyAsync(() -> {
long begin = System.currentTimeMillis();
List<RecallRequest> vecortSortBrandRequests = sortBrandRecallRequestBuilder.buildSortBrandRecallRequests(userRecallRequest.getUid(), userRecallRequest.getParamQueryFilter(), userPersonalFactor.getVectorSortBrandList(), SortBrandType.VEC_SORT_BRAND, SknCountConstants.VEC_SORT_BRAND_SKN_COUNT);
List<RecallRequestResponse> vecSortBrandRequestsResponses = batchRecallCacheBean.batchRecallAndCache(vecortSortBrandRequests);
RECALL_NEW_LOGGER.info("UserRecallCacheBean[2.4]-doRecallVectorSortBrand,requestCount is [{}], cost is [{}]", vecortSortBrandRequests.size(), System.currentTimeMillis() - begin);
List<RecallRequest> vectorRnnSortBrandRequests = sortBrandRecallRequestBuilder.buildSortBrandRecallRequests(userRecallRequest.getUid(), userRecallRequest.getParamQueryFilter(), userPersonalFactor.getVectorRnnSortBrandList(), SortBrandType.VEC_RNN_SORT_BRAND, SknCountConstants.VEC_SORT_BRAND_SKN_COUNT);
List<RecallRequestResponse> vecSortBrandRequestsResponses = batchRecallCacheBean.batchRecallAndCache(vectorRnnSortBrandRequests);
RECALL_NEW_LOGGER.info("UserRecallCacheBean[2.5]-doRecallVectorRnnSortBrand,requestCount is [{}], cost is [{}]", vectorRnnSortBrandRequests.size(), System.currentTimeMillis() - begin);
return vecSortBrandRequestsResponses;
}, recallExecutorService);
}
/**
* 执行预测【品牌+品类】的召回
* 执行w2v向量【品牌+品类】的召回
*
* @param userRecallRequest
* @param userPersonalFactor
* @return
*/
private CompletableFuture<List<RecallRequestResponse>> doRecallPredictSortBrand(UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) {
private CompletableFuture<List<RecallRequestResponse>> doRecallVectorW2vSortBrand(UserRecallRequest userRecallRequest, UserPersonalFactor userPersonalFactor) {
return CompletableFuture.supplyAsync(() -> {
long begin = System.currentTimeMillis();
List<RecallRequest> forecastSortBrandRequests = sortBrandRecallRequestBuilder.buildSortBrandRecallRequests(userRecallRequest.getUid(), userRecallRequest.getParamQueryFilter(), userPersonalFactor.getPredictSortBrandList(), SortBrandType.PRED_SORT_BRAND, SknCountConstants.PRED_SORT_BRAND_SKN_COUNT);
List<RecallRequestResponse> forecastSortBrandRequestsResponses = batchRecallCacheBean.batchRecallAndCache(forecastSortBrandRequests);
RECALL_NEW_LOGGER.info("UserRecallCacheBean[2.5]-doRecallPredictSortBrand,requestCount is [{}], cost is [{}]", forecastSortBrandRequests.size(), System.currentTimeMillis() - begin);
return forecastSortBrandRequestsResponses;
List<RecallRequest> vectorW2vSortBrandRequests = sortBrandRecallRequestBuilder.buildSortBrandRecallRequests(userRecallRequest.getUid(), userRecallRequest.getParamQueryFilter(), userPersonalFactor.getVectorW2vSortBrandList(), SortBrandType.VEC_W2V_SORT_BRAND, SknCountConstants.VEC_SORT_BRAND_SKN_COUNT);
List<RecallRequestResponse> vecSortBrandRequestsResponses = batchRecallCacheBean.batchRecallAndCache(vectorW2vSortBrandRequests);
RECALL_NEW_LOGGER.info("UserRecallCacheBean[2.6]-doRecallVectorW2vSortBrand,requestCount is [{}], cost is [{}]", vectorW2vSortBrandRequests.size(), System.currentTimeMillis() - begin);
return vecSortBrandRequestsResponses;
}, recallExecutorService);
}
... ...
... ... @@ -31,17 +31,18 @@ public class PagePersionalFactorComponent extends AbstractPageComponent<PagePers
/**
* 查询个性化因子
*
* @param paramQueryFilter
* @return
*/
public PagePersonalFactor queryPagePersionalFactor(ParamQueryFilter paramQueryFilter) {
Object value = super.queryWithCache(paramQueryFilter,PagePersonalFactor.class);
return value==null?null:(PagePersonalFactor)value;
Object value = super.queryWithCache(paramQueryFilter, PagePersonalFactor.class);
return value == null ? null : (PagePersonalFactor) value;
}
@Override
protected RedisKeyBuilder genRedisKeyBuilder(ParamQueryFilter paramQueryFilter) {
return RedisKeyBuilder.newInstance().appendFixed("YOHOSEARCH:").appendFixed("PAGE_FACTOR:").appendVar(paramQueryFilter.getParamMd5Key());
return RedisKeyBuilder.newInstance().appendFixed("YOHOSEARCH:").appendFixed("PAGE_FACTORS:").appendVar(paramQueryFilter.getParamMd5Key());
}
@Override
... ... @@ -74,17 +75,32 @@ public class PagePersionalFactorComponent extends AbstractPageComponent<PagePers
Map<String, Aggregation> aggregationMap = searchResult.getAggMaps();
List<SortBrand> sortBrands = this.getBrandSortsFromAggregationMap(aggregationMap);
List<Integer> misortIds = this.getMisortIds(sortBrands);
return new PagePersonalFactor(sortBrands,misortIds);
List<Integer> brandIds = this.getBrandIds(sortBrands);
return new PagePersonalFactor(misortIds, brandIds, sortBrands);
}
private List<Integer> getMisortIds(List<SortBrand> sortBrands){
if(sortBrands==null||sortBrands.isEmpty()){
private List<Integer> getMisortIds(List<SortBrand> sortBrands) {
if (sortBrands == null || sortBrands.isEmpty()) {
return new ArrayList<>();
}
List<Integer> results = new ArrayList<>();
for (SortBrand sortBrand : sortBrands) {
Integer misort = sortBrand.getMisort();
if(!results.contains(misort)){
if (!results.contains(misort)) {
results.add(misort);
}
}
return results;
}
private List<Integer> getBrandIds(List<SortBrand> sortBrands) {
if (sortBrands == null || sortBrands.isEmpty()) {
return new ArrayList<>();
}
List<Integer> results = new ArrayList<>();
for (SortBrand sortBrand : sortBrands) {
Integer misort = sortBrand.getMisort();
if (!results.contains(misort)) {
results.add(misort);
}
}
... ... @@ -102,14 +118,14 @@ public class PagePersionalFactorComponent extends AbstractPageComponent<PagePers
return middleSortAggBuilder;
}
private List<SortBrand> getBrandSortsFromAggregationMap(Map<String, Aggregation> aggregationMap) {
Map<Integer,List<Integer>> brand2MiSortIdsMap = this.getValueFromAggregationMap(aggregationMap,"sortBrandBrandIdAgg","sortBrandMiddleSortAgg");
private List<SortBrand> getBrandSortsFromAggregationMap(Map<String, Aggregation> aggregationMap) {
Map<Integer, List<Integer>> brand2MiSortIdsMap = this.getValueFromAggregationMap(aggregationMap, "sortBrandBrandIdAgg", "sortBrandMiddleSortAgg");
List<SortBrand> pageBrandSorts = new ArrayList<>();
for (Map.Entry<Integer,List<Integer>> entry: brand2MiSortIdsMap.entrySet()) {
for (Map.Entry<Integer, List<Integer>> entry : brand2MiSortIdsMap.entrySet()) {
Integer brandId = entry.getKey();
List<Integer> misorts = entry.getValue();
for (Integer misort: misorts) {
pageBrandSorts.add(new SortBrand(misort,brandId));
for (Integer misort : misorts) {
pageBrandSorts.add(new SortBrand(misort, brandId));
}
}
return pageBrandSorts;
... ... @@ -117,14 +133,15 @@ public class PagePersionalFactorComponent extends AbstractPageComponent<PagePers
/**
* 从聚合结果中获取参数,仅支持二层聚合
*
* @param aggregationMap
* @param firstAggName
* @param secondAggName
* @return
*/
private Map<Integer,List<Integer>> getValueFromAggregationMap(Map<String, Aggregation> aggregationMap,String firstAggName,String secondAggName){
Map<Integer,List<Integer>> aggResultMap = new HashMap<>();
if(!aggregationMap.containsKey(firstAggName)){
private Map<Integer, List<Integer>> getValueFromAggregationMap(Map<String, Aggregation> aggregationMap, String firstAggName, String secondAggName) {
Map<Integer, List<Integer>> aggResultMap = new HashMap<>();
if (!aggregationMap.containsKey(firstAggName)) {
return aggResultMap;
}
MultiBucketsAggregation firstAggregation = (MultiBucketsAggregation) aggregationMap.get(firstAggName);
... ... @@ -132,19 +149,19 @@ public class PagePersionalFactorComponent extends AbstractPageComponent<PagePers
while (firstAggregationIterator.hasNext()) {
MultiBucketsAggregation.Bucket firstAggregationBucket = firstAggregationIterator.next();
Integer firstAggregationBucketKey = Integer.valueOf(firstAggregationBucket.getKeyAsString());
Map<String, Aggregation> secondAggregationMap = firstAggregationBucket.getAggregations().asMap();
if(secondAggregationMap==null || !secondAggregationMap.containsKey(secondAggName)){
Map<String, Aggregation> secondAggregationMap = firstAggregationBucket.getAggregations().asMap();
if (secondAggregationMap == null || !secondAggregationMap.containsKey(secondAggName)) {
continue;
}
List<Integer> secondAggregationBucketKeys = this.getAggValuesFromMultiBucketsAggregation((MultiBucketsAggregation)secondAggregationMap.get(secondAggName));
aggResultMap.put(firstAggregationBucketKey,secondAggregationBucketKeys);
List<Integer> secondAggregationBucketKeys = this.getAggValuesFromMultiBucketsAggregation((MultiBucketsAggregation) secondAggregationMap.get(secondAggName));
aggResultMap.put(firstAggregationBucketKey, secondAggregationBucketKeys);
}
return aggResultMap;
}
private List<Integer> getAggValuesFromMultiBucketsAggregation(MultiBucketsAggregation aggregation){
private List<Integer> getAggValuesFromMultiBucketsAggregation(MultiBucketsAggregation aggregation) {
List<Integer> results = new ArrayList<>();
if(aggregation==null){
if (aggregation == null) {
return results;
}
Iterator<? extends MultiBucketsAggregation.Bucket> bucketsIterator = aggregation.getBuckets().iterator();
... ...
... ... @@ -53,29 +53,26 @@ public class QueryUserPersionalFactorBean {
long begin = System.currentTimeMillis();
PagePersonalFactor pageFactor = pageComponent.queryPagePersionalFactor(userRecallRequest.getParamQueryFilter());
long cost = System.currentTimeMillis() - begin;
RECALL_NEW_LOGGER.info("QueryUserPersionalFactorBean[1]:queryPageFactor. uid is[{}],udid is[{}], cost is[{}],size is[{}] ", uid, udid, cost, pageFactor == null ? "null" : pageFactor.sortBrandListSize());
RECALL_NEW_LOGGER.info("QueryUserPersionalFactorBean[1]:queryPageFactor. uid is[{}],udid is[{}], cost is[{}]] ms", uid, udid, cost);
//2、获取用户的个性化因子
begin = System.currentTimeMillis();
UserPersonalFactorRspNew userFactor = userComponent.queryUserPersionalFactor(userRecallRequest.getUid(), userRecallRequest.getUdid(), pageFactor.getMisortIds());
cost = System.currentTimeMillis() - begin;
int forecastSortBrandSize = userFactor.getSortBrandList().size();
int realTimeSortBrandSize = userFactor.getRealTimeSortBrandList().size();
int recommendSknSize = userFactor.getRecommendSknList().size();
if (!openDetailLog) {
RECALL_NEW_LOGGER.info("QueryUserPersionalFactorBean[2]:queryUserFactor. uid is[{}],udid is[{}], cost is[{}], forecastSortBrandSize is[{}],realTimeSortBrandSize is[{}], recommendSknSize is[{}] ", uid, udid, cost, forecastSortBrandSize, realTimeSortBrandSize, recommendSknSize);
} else {
RECALL_NEW_LOGGER.info("QueryUserPersionalFactorBean[2]:queryUserFactor. uid is[{}],udid is[{}], cost is[{}], forecastSortBrandSize is[{}],realTimeSortBrandSize is[{}], recommendSknSize is[{}],misortIds is[{}],userFactor is[{}] ", uid, udid, cost, forecastSortBrandSize, realTimeSortBrandSize, recommendSknSize, pageFactor.getMisortIds(), JSON.toJSONString(userFactor));
}
StringBuilder sizeLogInfo = new StringBuilder();
sizeLogInfo.append("SKN_SIZE is ").append(userFactor.getRecommendSknList().size()).append(";");
sizeLogInfo.append("RT_SB_SIZE is ").append(userFactor.getRealTimeSortBrandList().size()).append(";");
sizeLogInfo.append("PRED_SB_SIZE is ").append(userFactor.getSortBrandList().size()).append(";");
sizeLogInfo.append("VECTOR_RNN_SIZE is ").append(userFactor.getBrandVector().size()).append("_").append(userFactor.getSortBrandVector().size()).append(";");
sizeLogInfo.append("VECTOR_W2C_SIZE is ").append(userFactor.getBrandVectorW2v().size()).append("_").append(userFactor.getSortBrandVectorW2v().size()).append(";");
RECALL_NEW_LOGGER.info("QueryUserPersionalFactorBean[2]:queryUserFactor. uid is[{}],udid is[{}], cost is[{}], size info is [{}] ", uid, udid, cost, sizeLogInfo.toString());
//3、构造结果
begin = System.currentTimeMillis();
UserPersonalFactor userPersonalFactor = this.buildUserPersonalFactor(pageFactor, userFactor);
cost = System.currentTimeMillis() - begin;
if (!openDetailLog) {
RECALL_NEW_LOGGER.info("QueryUserPersionalFactorBean[3]:buildUserPersonalFactor.cost is[{}ms], uid is[{}],udid is[{}], predictSortBrandSize size is[{}], realTimeSortBrand size is[{}], vectorSortBrand size is[{}], sortPriceAreas size is [{}] ", cost, uid, udid, userPersonalFactor.getPredictSortBrandListSize(), userPersonalFactor.getRealTimeSortBrandListSize(), userPersonalFactor.getVectorSortBrandListSize(), userPersonalFactor.getSortPriceAreasListSize());
} else {
RECALL_NEW_LOGGER.info("QueryUserPersionalFactorBean[3]:buildUserPersonalFactor.cost is[{}ms], uid is[{}],udid is[{}], predictSortBrandSize size is[{}], realTimeSortBrand size is[{}], vectorSortBrand size is[{}], sortPriceAreas size is [{}], results is [{}] ", cost, uid, udid, userPersonalFactor.getPredictSortBrandListSize(), userPersonalFactor.getRealTimeSortBrandListSize(), userPersonalFactor.getVectorSortBrandListSize(), userPersonalFactor.getSortPriceAreasListSize(), JSON.toJSONString(userPersonalFactor));
}
RECALL_NEW_LOGGER.info("QueryUserPersionalFactorBean[3]:buildUserPersonalFactor, uid is[{}],udid is[{}], cost is[{}ms],", uid, udid, cost);
return userPersonalFactor;
} catch (Exception e) {
logger.error(e.getMessage(), e);
... ... @@ -84,39 +81,43 @@ public class QueryUserPersionalFactorBean {
}
private UserPersonalFactor buildUserPersonalFactor(PagePersonalFactor pageFactor, UserPersonalFactorRspNew userFactor) {
//1、获取页面中存在的所有的key
//1、构造品类价格带
List<SortPriceAreas> sortPriceAreasList = this.getSortPriceAreasListWithSort(userFactor, pageFactor);
//2、构造推荐的skn列表
List<Integer> recommendSknList = userFactor.getRecommendSknList();
//3、获取页面中存在的所有的key
Set<String> pageSortBrandKeys = new HashSet<>();
Set<String> filterSortBrandKeys = new HashSet<>();
for (SortBrand pageSortBrand : pageFactor.getSortBrandList()) {
pageSortBrandKeys.add(pageSortBrand.key());
}
//2、构造实时【品类+品牌】
//4、构造实时【品类+品牌】
int maxRealTimeSortBrandCount = RecallCommonConstants.maxRealTimeSortBrandCount;
List<SortBrand> realTimeSortBrandList = this.getSortBrandListWithSort(pageSortBrandKeys, filterSortBrandKeys, userFactor.getRealTimeSortBrandList(), maxRealTimeSortBrandCount);
for (SortBrand existSortBrand : realTimeSortBrandList) {
filterSortBrandKeys.add(existSortBrand.key());
}
//3、构造基于向量的【品牌+品牌】,去除实时的品类和品牌
int maxVectorSortBrandCount = RecallCommonConstants.maxVectorSortBrandCount;
List<SortBrand> vectorSortBrandList = sortBrandVectorComponent.queryRnnVectorSortBrandList(pageFactor.getSortBrandList(), filterSortBrandKeys, userFactor.getSortBrandVector(), maxVectorSortBrandCount);
for (SortBrand existSortBrand : vectorSortBrandList) {
filterSortBrandKeys.add(existSortBrand.key());
}
//4、构造预测的【品牌+品牌】,去除实时的品类和品牌
//5、构造预测的【品牌+品牌】,去除实时的品类和品牌
int maxPredictSortBrandCount = RecallCommonConstants.maxPredictSortBrandCount;
List<SortBrand> forecastSortBrandList = this.getSortBrandListWithSort(pageSortBrandKeys, filterSortBrandKeys, userFactor.getSortBrandList(), maxPredictSortBrandCount);
for (SortBrand existSortBrand : forecastSortBrandList) {
filterSortBrandKeys.add(existSortBrand.key());
}
//5、构造品类价格带
List<SortPriceAreas> sortPriceAreasList = this.getSortPriceAreasListWithSort(userFactor, pageFactor);
//6、构造推荐的skn列表
List<Integer> recommendSknList = userFactor.getRecommendSknList();
//7、返回最终结果
return new UserPersonalFactor(realTimeSortBrandList, forecastSortBrandList, vectorSortBrandList, sortPriceAreasList, recommendSknList);
//6、构造基于RNN向量的【品牌+品牌】,去除实时的品类和品牌
int maxVectorRNNSortBrandCount = RecallCommonConstants.maxVectorRNNSortBrandCount;
List<SortBrand> vectorRnnSortBrandList = sortBrandVectorComponent.queryRnnVectorSortBrandList(pageFactor, filterSortBrandKeys, userFactor.getBrandVector(), userFactor.getSortBrandVector(), maxVectorRNNSortBrandCount);
for (SortBrand existSortBrand : vectorRnnSortBrandList) {
filterSortBrandKeys.add(existSortBrand.key());
}
//7、构造基于W2V向量的【品牌+品牌】,去除实时的品类和品牌
int maxVectorW2SortBrandCount = RecallCommonConstants.maxVectorW2SortBrandCount;
List<SortBrand> vectorW2vSortBrandList = sortBrandVectorComponent.queryW2VectorSortBrandList(pageFactor, filterSortBrandKeys, userFactor.getBrandVector(), userFactor.getSortBrandVectorW2v(), maxVectorW2SortBrandCount);
for (SortBrand existSortBrand : vectorW2vSortBrandList) {
filterSortBrandKeys.add(existSortBrand.key());
}
//8、返回最终结果
return new UserPersonalFactor(recommendSknList, sortPriceAreasList, realTimeSortBrandList, forecastSortBrandList, vectorRnnSortBrandList, vectorW2vSortBrandList);
}
private List<SortBrand> getSortBrandListWithSort(Set<String> pageSortBrandKeys, Set<String> filterSortBrandKeys, List<SortBrand> userSortBrands, int maxCount) {
... ...
... ... @@ -29,27 +29,45 @@ public class UserPersionalFactorComponent {
* @param udid
* @return
*/
public UserPersonalFactorRspNew queryUserPersionalFactor(int uid, String udid,List<Integer> misortIds) {
public UserPersonalFactorRspNew queryUserPersionalFactor(int uid, String udid, List<Integer> misortIds) {
try {
UserPersonalFactorReq userPersionalFactorReq = new UserPersonalFactorReq(uid, udid,misortIds);
UserPersonalFactorReq userPersionalFactorReq = new UserPersonalFactorReq(uid, udid, misortIds);
JSONObject result = serviceCaller.call(SERVICE_NAME, userPersionalFactorReq, JSONObject.class, timeOut);
JSONObject userPersonalFactorRspJSon = result.getJSONObject("data");
UserPersonalFactorRspNew rsp = JSON.toJavaObject(userPersonalFactorRspJSon, UserPersonalFactorRspNew.class);
if (rsp == null) {
rsp = new UserPersonalFactorRspNew();
}
if(rsp.getSortBrandList()==null){
rsp.setSortBrandList(new ArrayList<>());
//skn
if (rsp.getRecommendSknList() == null) {
rsp.setRecommendSknList(new ArrayList<>());
}
//价格带
if (rsp.getSortPriceAreasList() == null) {
rsp.setSortPriceAreasList(new ArrayList<>());
}
if(rsp.getRealTimeSortBrandList()==null){
//实时的品类品牌
if (rsp.getRealTimeSortBrandList() == null) {
rsp.setRealTimeSortBrandList(new ArrayList<>());
}
if(rsp.getSortPriceAreasList()==null){
rsp.setSortPriceAreasList(new ArrayList<>());
//预测的品类品牌
if (rsp.getSortBrandList() == null) {
rsp.setSortBrandList(new ArrayList<>());
}
//RNN的向量
if (rsp.getBrandVector() == null) {
rsp.setBrandVector(new ArrayList<>());
}
if(rsp.getSortBrandVector()==null){
if (rsp.getSortBrandVector() == null) {
rsp.setSortBrandVector(new ArrayList<>());
}
//w2v的的向量
if (rsp.getSortBrandVectorW2v() == null) {
rsp.setSortBrandVectorW2v(new ArrayList<>());
}
if (rsp.getBrandVectorW2v() == null) {
rsp.setBrandVectorW2v(new ArrayList<>());
}
return rsp;
} catch (Exception e) {
RECALL_NEW_LOGGER.error(e.getMessage(), e);
... ...
... ... @@ -3,5 +3,6 @@ package com.yoho.search.recall.scene.beans.strategy;
public enum SortBrandType {
REC_SORT_BRAND,
PRED_SORT_BRAND,
VEC_SORT_BRAND
VEC_RNN_SORT_BRAND,
VEC_W2V_SORT_BRAND
}
... ...
... ... @@ -7,23 +7,29 @@ public enum StrategyEnum {
REC_SKN(99),//实时推荐的skn
REC_S_B_HEAT_VALUE(40),//实时的品牌+品类的人气值
REC_S_B_CTR_VALUE(41),//实时的品牌+品类的转化率
REC_S_B_REDUCE_PRICE(42),//实时的品牌+品类的最新降价
REC_S_B_PROMOTION(43),//实时的品牌+品类的新开促销
REC_S_B_NEW(44),//实时的品牌+品类的新品
VEC_S_B_HEAT_VALUE(30),//向量预测的品牌+品类的人气值
VEC_S_B_CTR_VALUE(31),//实时的品牌+品类的转化率
VEC_S_B_REDUCE_PRICE(32),//向量预测的品牌+品类的最新降价
VEC_S_B_PROMOTION(33),//向量预测的品牌+品类的新开促销
VEC_S_B_NEW(34),//向量预测的品牌+品类的新品
PRED_S_B_HEAT_VALUE(20),//预测的品牌+品类的人气值
PRED_S_B_CTR_VALUE(21),//预测的品牌+品类的转化率
PRED_S_B_REDUCE_PRICE(22),//预测的品牌+品类的最新降价
PRED_S_B_PROMOTION(23),//预测的品牌+品类的新开促销
PRED_S_B_NEW(24),//预测的品牌+品类的新品
REC_S_B_HEAT_VALUE(80),//实时的品牌+品类的人气值
REC_S_B_CTR_VALUE(81),//实时的品牌+品类的转化率
REC_S_B_REDUCE_PRICE(82),//实时的品牌+品类的最新降价
REC_S_B_PROMOTION(83),//实时的品牌+品类的新开促销
REC_S_B_NEW(84),//实时的品牌+品类的新品
PRED_S_B_HEAT_VALUE(70),//预测的品牌+品类的人气值
PRED_S_B_CTR_VALUE(71),//预测的品牌+品类的转化率
PRED_S_B_REDUCE_PRICE(72),//预测的品牌+品类的最新降价
PRED_S_B_PROMOTION(73),//预测的品牌+品类的新开促销
PRED_S_B_NEW(74),//预测的品牌+品类的新品
VEC_RNN_S_B_HEAT_VALUE(60),//向量预测的品牌+品类的人气值
VEC_RNN_S_B_CTR_VALUE(61),//实时的品牌+品类的转化率
VEC_RNN_S_B_REDUCE_PRICE(62),//向量预测的品牌+品类的最新降价
VEC_RNN_S_B_PROMOTION(63),//向量预测的品牌+品类的新开促销
VEC_RNN_S_B_NEW(64),//向量预测的品牌+品类的新品
VEC_W2V_S_B_HEAT_VALUE(50),//向量预测的品牌+品类的人气值
VEC_W2V_S_B_CTR_VALUE(51),//实时的品牌+品类的转化率
VEC_W2V_S_B_REDUCE_PRICE(52),//向量预测的品牌+品类的最新降价
VEC_W2V_S_B_PROMOTION(53),//向量预测的品牌+品类的新开促销
VEC_W2V_S_B_NEW(54),//向量预测的品牌+品类的新品
ADD_FLOW(12),//流量补偿
NEW_SHOP(11),//新开店铺
... ...
... ... @@ -16,7 +16,7 @@ public abstract class SortBrandAbstractStrategy implements IStrategy {
public SortBrandAbstractStrategy(SortBrand sortBrand, int size, SortBrandType sortBrandType) {
this.sortBrand = sortBrand;
this.size = size;
this.sortBrandType=sortBrandType;
this.sortBrandType = sortBrandType;
}
@Override
... ... @@ -32,71 +32,81 @@ public abstract class SortBrandAbstractStrategy implements IStrategy {
@Override
public String strategyCacheKey() {
StringBuilder sb = defaultStrategyKey();
sb.append(this.sortBrand==null?"": JSON.toJSONString(this.sortBrand));
sb.append(this.sortBrand == null ? "" : JSON.toJSONString(this.sortBrand));
return sb.toString();
}
public StrategyEnum heatValueStrategyEnum(SortBrandType sortBrandType){
switch (sortBrandType){
public StrategyEnum heatValueStrategyEnum(SortBrandType sortBrandType) {
switch (sortBrandType) {
case REC_SORT_BRAND:
return StrategyEnum.REC_S_B_HEAT_VALUE;
case PRED_SORT_BRAND:
return StrategyEnum.PRED_S_B_HEAT_VALUE;
case VEC_SORT_BRAND:
return StrategyEnum.VEC_S_B_HEAT_VALUE;
case VEC_RNN_SORT_BRAND:
return StrategyEnum.VEC_RNN_S_B_HEAT_VALUE;
case VEC_W2V_SORT_BRAND:
return StrategyEnum.VEC_W2V_S_B_HEAT_VALUE;
default:
return null;
}
}
public StrategyEnum ctrValueStrategyEnum(SortBrandType sortBrandType){
switch (sortBrandType){
public StrategyEnum ctrValueStrategyEnum(SortBrandType sortBrandType) {
switch (sortBrandType) {
case REC_SORT_BRAND:
return StrategyEnum.REC_S_B_CTR_VALUE;
case PRED_SORT_BRAND:
return StrategyEnum.PRED_S_B_CTR_VALUE;
case VEC_SORT_BRAND:
return StrategyEnum.VEC_S_B_CTR_VALUE;
case VEC_RNN_SORT_BRAND:
return StrategyEnum.VEC_RNN_S_B_CTR_VALUE;
case VEC_W2V_SORT_BRAND:
return StrategyEnum.VEC_W2V_S_B_CTR_VALUE;
default:
return null;
}
}
public StrategyEnum newStrategyEnum(SortBrandType sortBrandType){
switch (sortBrandType){
public StrategyEnum newStrategyEnum(SortBrandType sortBrandType) {
switch (sortBrandType) {
case REC_SORT_BRAND:
return StrategyEnum.REC_S_B_NEW;
case PRED_SORT_BRAND:
return StrategyEnum.PRED_S_B_NEW;
case VEC_SORT_BRAND:
return StrategyEnum.VEC_S_B_NEW;
case VEC_RNN_SORT_BRAND:
return StrategyEnum.VEC_RNN_S_B_NEW;
case VEC_W2V_SORT_BRAND:
return StrategyEnum.VEC_W2V_S_B_NEW;
default:
return null;
}
}
public StrategyEnum promotionStrategyEnum(SortBrandType sortBrandType){
switch (sortBrandType){
public StrategyEnum promotionStrategyEnum(SortBrandType sortBrandType) {
switch (sortBrandType) {
case REC_SORT_BRAND:
return StrategyEnum.REC_S_B_PROMOTION;
case PRED_SORT_BRAND:
return StrategyEnum.PRED_S_B_PROMOTION;
case VEC_SORT_BRAND:
return StrategyEnum.VEC_S_B_PROMOTION;
case VEC_RNN_SORT_BRAND:
return StrategyEnum.VEC_RNN_S_B_PROMOTION;
case VEC_W2V_SORT_BRAND:
return StrategyEnum.VEC_W2V_S_B_PROMOTION;
default:
return null;
}
}
public StrategyEnum reducePriceStrategyEnum(SortBrandType sortBrandType){
switch (sortBrandType){
public StrategyEnum reducePriceStrategyEnum(SortBrandType sortBrandType) {
switch (sortBrandType) {
case REC_SORT_BRAND:
return StrategyEnum.REC_S_B_REDUCE_PRICE;
case PRED_SORT_BRAND:
return StrategyEnum.PRED_S_B_REDUCE_PRICE;
case VEC_SORT_BRAND:
return StrategyEnum.VEC_S_B_REDUCE_PRICE;
case VEC_RNN_SORT_BRAND:
return StrategyEnum.VEC_RNN_S_B_REDUCE_PRICE;
case VEC_W2V_SORT_BRAND:
return StrategyEnum.VEC_W2V_S_B_REDUCE_PRICE;
default:
return null;
}
... ...
... ... @@ -4,6 +4,7 @@ import com.yoho.search.base.helper.RnnVectorCalculator;
import com.yoho.search.base.helper.Word2VectorCalculator;
import com.yoho.search.base.utils.CollectionUtils;
import com.yoho.search.core.personalized.models.SortBrand;
import com.yoho.search.recall.scene.models.personal.PagePersonalFactor;
import com.yoho.search.recall.scene.models.personal.SortBrandVectorScore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -19,20 +20,24 @@ public class SortBrandVectorComponent {
@Autowired
private SortBrandVectorCacheBean sortBrandVectorCacheBean;
public List<SortBrand> queryRnnVectorSortBrandList(List<SortBrand> pageSortBrands, Set<String> filterKeys, List<Double> userVectorList, int filterCount) {
if (userVectorList == null || userVectorList.isEmpty()) {
public List<SortBrand> queryRnnVectorSortBrandList(PagePersonalFactor pageFactor, Set<String> filterSortBrandKeys, List<Double> userBrandVector, List<Double> userSortBrandVector, int filterCount) {
if (userSortBrandVector == null || userSortBrandVector.isEmpty()) {
return new ArrayList<>();
}
List<SortBrand> pageSortBrands = pageFactor.getSortBrandList();
if (pageSortBrands == null || pageSortBrands.isEmpty()) {
return new ArrayList<>();
}
List<SortBrandVectorScore> sortBrandVectorScores = new ArrayList<>();
for (SortBrand sortBrand : pageSortBrands) {
if (filterKeys.contains(sortBrand.key())) {
if (filterSortBrandKeys.contains(sortBrand.key())) {
continue;
}
List<Double> sortBrandVector = sortBrandVectorCacheBean.queryBrandSortVector(sortBrand,true);
List<Double> sortBrandVector = sortBrandVectorCacheBean.queryBrandSortVector(sortBrand, true);
if (sortBrandVector == null || sortBrandVector.isEmpty()) {
continue;
}
double score = RnnVectorCalculator.calScore(userVectorList, sortBrandVector);
double score = RnnVectorCalculator.calScore(userSortBrandVector, sortBrandVector);
sortBrandVectorScores.add(new SortBrandVectorScore(sortBrand, score));
}
Collections.sort(sortBrandVectorScores, (o1, o2) -> o2.getScore().compareTo(o1.getScore()));//得分高的排在前面
... ... @@ -44,21 +49,25 @@ public class SortBrandVectorComponent {
return result;
}
public List<SortBrand> queryW2VectorSortBrandList(List<SortBrand> pageSortBrands, Set<String> filterKeys, List<Double> userVectorList, int filterCount) {
if (userVectorList == null || userVectorList.isEmpty()) {
public List<SortBrand> queryW2VectorSortBrandList(PagePersonalFactor pageFactor, Set<String> filterSortBrandKeys, List<Double> userBrandVector, List<Double> userSortBrandVector, int filterCount) {
if (userSortBrandVector == null || userSortBrandVector.isEmpty()) {
return new ArrayList<>();
}
List<SortBrand> pageSortBrands = pageFactor.getSortBrandList();
if (pageSortBrands == null || pageSortBrands.isEmpty()) {
return new ArrayList<>();
}
List<SortBrandVectorScore> sortBrandVectorScores = new ArrayList<>();
double userVectorListNorm = Word2VectorCalculator.getVectorListNorm(userVectorList);
double userVectorListNorm = Word2VectorCalculator.getVectorListNorm(userSortBrandVector);
for (SortBrand sortBrand : pageSortBrands) {
if (filterKeys.contains(sortBrand.key())) {
if (filterSortBrandKeys.contains(sortBrand.key())) {
continue;
}
List<Double> sortBrandVector = sortBrandVectorCacheBean.queryBrandSortVector(sortBrand,false);
List<Double> sortBrandVector = sortBrandVectorCacheBean.queryBrandSortVector(sortBrand, false);
if (sortBrandVector == null || sortBrandVector.isEmpty()) {
continue;
}
double score = Word2VectorCalculator.calScore(userVectorList, userVectorListNorm, sortBrandVector);
double score = Word2VectorCalculator.calScore(userSortBrandVector, userVectorListNorm, sortBrandVector);
sortBrandVectorScores.add(new SortBrandVectorScore(sortBrand, score));
}
Collections.sort(sortBrandVectorScores, (o1, o2) -> o2.getScore().compareTo(o1.getScore()));//得分高的排在前面
... ...
... ... @@ -7,31 +7,31 @@ package com.yoho.search.recall.scene.constants;
public class CacheTimeConstants {
//通用召回的缓存
public static final int COMMON_RECALL_STRATEGY_CACHE_TIME = 5 ;
public static final int COMMON_RECALL_STRATEGY_CACHE_TIME = 5;
//SKN的的缓存
public static final int SKN_RECALL_CACHE_TIME = 10 ;
public static final int SKN_RECALL_CACHE_TIME = 10;
//品类+品牌的缓存
public static final int SORT_BRAND_RECALL_STRATEGY_CACHE_TIME = 60 ;
public static final int SORT_BRAND_RECALL_STRATEGY_CACHE_TIME = 60;
//SKN基本信息的缓存
public static final int SKN_BASE_INFO = 60 ;
public static final int SKN_BASE_INFO = 60;
//SKN返回信息的缓存
public static final int SKN_RETURN_INFO = 2 ;
public static final int SKN_RETURN_INFO = 3;
//用户召回结果的缓存
public static final int USER_RECALL_SKN_LIST = 3 ;
public static final int USER_RECALL_SKN_LIST = 3;
//页面skn的bitset缓存
public static final int PAGE_SKN_BITSET = 60 ;
public static final int PAGE_SKN_BITSET = 60;
//页面个性化因子的缓存
public static final int PAGE_PERSIONAL_FACTOR = 60 ;
public static final int PAGE_PERSIONAL_FACTOR = 60;
public static final int CACHE_60_MINUTE = 60 ;
public static final int CACHE_60_MINUTE = 60;
public static final int CACHE_10_MINUTE = 10 ;
public static final int CACHE_10_MINUTE = 10;
}
... ...
... ... @@ -4,8 +4,11 @@ public class RecallCommonConstants {
public static final int maxRealTimeSortBrandCount = 15;//截取【品牌-品类】的数量-for召回【10->12】
public static final int maxVectorSortBrandCount = 6;//截取【品牌-品类】的数量-for召回【10->6】
public static final int maxPredictSortBrandCount = 6;//截取【品牌-品类】的数量-for召回【10->6】
public static final int maxVectorRNNSortBrandCount = 6;//截取【品牌-品类】的数量-for召回【10->6】
public static final int maxVectorW2SortBrandCount = 6;//截取【品牌-品类】的数量-for召回【10->6】
}
... ...
... ... @@ -13,21 +13,15 @@ public class PagePersonalFactor implements Serializable {
private static final long serialVersionUID = 89030356435559223L;
private List<Integer> misortIds;
private List<Integer> brandIds;
private List<SortBrand> sortBrandList;
public PagePersonalFactor() {
}
public PagePersonalFactor(List<SortBrand> sortBrandList, List<Integer> misortIds) {
this.sortBrandList = sortBrandList;
public PagePersonalFactor(List<Integer> misortIds, List<Integer> brandIds, List<SortBrand> sortBrandList) {
this.misortIds = misortIds;
}
public List<SortBrand> getSortBrandList() {
return sortBrandList;
}
public void setSortBrandList(List<SortBrand> sortBrandList) {
this.brandIds = brandIds;
this.sortBrandList = sortBrandList;
}
... ... @@ -39,8 +33,19 @@ public class PagePersonalFactor implements Serializable {
this.misortIds = misortIds;
}
public int sortBrandListSize() {
return sortBrandList==null?0:sortBrandList.size();
public List<Integer> getBrandIds() {
return brandIds;
}
public void setBrandIds(List<Integer> brandIds) {
this.brandIds = brandIds;
}
public List<SortBrand> getSortBrandList() {
return sortBrandList;
}
public void setSortBrandList(List<SortBrand> sortBrandList) {
this.sortBrandList = sortBrandList;
}
}
... ...
... ... @@ -8,62 +8,56 @@ import java.util.List;
public class UserPersonalFactor {
private List<Integer> recommendSknList;
private List<SortPriceAreas> sortPriceAreasList;
private List<SortBrand> realTimeSortBrandList;
private List<SortBrand> predictSortBrandList;
private List<SortBrand> vectorSortBrandList;
private List<SortPriceAreas> sortPriceAreasList;
private List<Integer> recommendSknList;
private List<SortBrand> vectorRnnSortBrandList;
private List<SortBrand> vectorW2vSortBrandList;
public UserPersonalFactor() {
this.recommendSknList = new ArrayList<>();
this.sortPriceAreasList = new ArrayList<>();
this.realTimeSortBrandList = new ArrayList<>();
this.predictSortBrandList = new ArrayList<>();
this.vectorSortBrandList = new ArrayList<>();
this.sortPriceAreasList = new ArrayList<>();
this.recommendSknList = new ArrayList<>();
this.vectorRnnSortBrandList = new ArrayList<>();
this.vectorW2vSortBrandList = new ArrayList<>();
}
public UserPersonalFactor(List<SortBrand> realTimeSortBrandList, List<SortBrand> predictSortBrandList, List<SortBrand> vectorSortBrandList, List<SortPriceAreas> sortPriceAreasList, List<Integer> recommendSknList) {
this.realTimeSortBrandList = realTimeSortBrandList;
this.predictSortBrandList = predictSortBrandList;
this.vectorSortBrandList = vectorSortBrandList;
this.sortPriceAreasList = sortPriceAreasList;
public UserPersonalFactor(List<Integer> recommendSknList, List<SortPriceAreas> sortPriceAreasList, List<SortBrand> realTimeSortBrandList, List<SortBrand> predictSortBrandList, List<SortBrand> vectorRnnSortBrandList, List<SortBrand> vectorW2vSortBrandList) {
this.recommendSknList = recommendSknList;
}
public List<SortBrand> getRealTimeSortBrandList() {
return realTimeSortBrandList;
}
this.sortPriceAreasList = sortPriceAreasList;
public List<SortBrand> getPredictSortBrandList() {
return predictSortBrandList;
this.realTimeSortBrandList = realTimeSortBrandList;
this.predictSortBrandList = predictSortBrandList;
this.vectorRnnSortBrandList = vectorRnnSortBrandList;
this.vectorW2vSortBrandList = vectorW2vSortBrandList;
}
public List<SortBrand> getVectorSortBrandList() {
return vectorSortBrandList;
public List<Integer> getRecommendSknList() {
return recommendSknList;
}
public List<SortPriceAreas> getSortPriceAreasList() {
return sortPriceAreasList;
}
public List<Integer> getRecommendSknList() {
return recommendSknList;
}
public int getRealTimeSortBrandListSize() {
return realTimeSortBrandList == null ? 0 : realTimeSortBrandList.size();
public List<SortBrand> getRealTimeSortBrandList() {
return realTimeSortBrandList;
}
public int getPredictSortBrandListSize() {
return predictSortBrandList == null ? 0 : predictSortBrandList.size();
public List<SortBrand> getPredictSortBrandList() {
return predictSortBrandList;
}
public int getVectorSortBrandListSize() {
return vectorSortBrandList == null ? 0 : vectorSortBrandList.size();
public List<SortBrand> getVectorRnnSortBrandList() {
return vectorRnnSortBrandList;
}
public int getSortPriceAreasListSize() {
return sortPriceAreasList == null ? 0 : sortPriceAreasList.size();
public List<SortBrand> getVectorW2vSortBrandList() {
return vectorW2vSortBrandList;
}
}
... ...
... ... @@ -41,28 +41,25 @@ public class UserVectorSortBrandService {
int pageSize = MapUtils.getIntValue(paramMap, SearchRequestParams.PARAM_SEARCH_VIEWNUM, 20);
UserRecallRequest userRecallRequest = userRecallRequestBuilder.buildUserRecallRequest(paramMap, pageSize);
UserPersonalFactor userPersonalFactor = queryUserPersionalFactorBean.queryPersionalFactor(userRecallRequest);
Map<String, Object> results = new HashMap<>();
//uid+udid
results.put("uid", userRecallRequest.getUid());
results.put("udid", userRecallRequest.getUdid());
//推荐的skn
results.put("recommendSknList", userPersonalFactor.getRecommendSknList());
//用户价格带
results.put("sortPriceAreasList", this.querySortPriceAreasList(userPersonalFactor.getSortPriceAreasList()));
//实时的品类品牌
results.put("realTimeSortBrandList", this.querySortBrands(userPersonalFactor.getRealTimeSortBrandList()));
//RNN预测的品类品牌
results.put("predictSortBrandList", this.querySortBrands(userPersonalFactor.getPredictSortBrandList()));
//向量预测的品类品牌
results.put("vectorSortBrandList", this.querySortBrands(userPersonalFactor.getVectorSortBrandList()));
//rnn向量预测的品类品牌
results.put("vectorRnnSortBrandList", this.querySortBrands(userPersonalFactor.getVectorRnnSortBrandList()));
//w2v向量预测的品类品牌
results.put("vectorW2vSortBrandList", this.querySortBrands(userPersonalFactor.getVectorW2vSortBrandList()));
return new SearchApiResult().setData(results);
} catch (Exception e) {
return new SearchApiResult();
return new SearchApiResult().setMessage(e.getMessage());
}
}
... ...