Authored by hugufei

商品召回后基本信息在排序阶段统一填充

Showing 21 changed files with 382 additions and 568 deletions
... ... @@ -9,8 +9,8 @@ import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.core.es.model.SearchResult;
import com.yoho.search.models.SearchApiResult;
import com.yoho.search.recall.scene.beans.builder.UserRecallRequestBuilder;
import com.yoho.search.recall.scene.beans.cache.SknInfoResqusetResponseCacheBean;
import com.yoho.search.recall.scene.beans.cache.UserRecallRequestResponseCacheBean;
import com.yoho.search.recall.scene.beans.cache.SknReturnInfoCacheBean;
import com.yoho.search.recall.scene.beans.cache.UserRecallCacheBean;
import com.yoho.search.recall.scene.beans.helper.SortBuilderHelper;
import com.yoho.search.recall.scene.beans.strategy.StrategyEnum;
import com.yoho.search.recall.scene.models.req.UserRecallRequest;
... ... @@ -45,9 +45,9 @@ public class SceneRecallProductListService {
@Autowired
private SearchCommonService searchCommonService;
@Autowired
private UserRecallRequestResponseCacheBean userRecallRequestResponseCacheBean;
private UserRecallCacheBean userRecallCacheBean;
@Autowired
private SknInfoResqusetResponseCacheBean sknInfoResqusetResponseCacheBean;
private SknReturnInfoCacheBean sknReturnInfoCacheBean;
@Autowired
private SearchDynamicConfigService searchDynamicConfigService;
... ... @@ -89,7 +89,7 @@ public class SceneRecallProductListService {
//2、执行召回
long begin = System.currentTimeMillis();
UserRecallResponse userRecallResponse = userRecallRequestResponseCacheBean.queryRecallResult(userRecallRequest,ignoreQueryCache);
UserRecallResponse userRecallResponse = userRecallCacheBean.queryRecallResult(userRecallRequest,ignoreQueryCache);
RECALL_NEW_LOGGER.info("SceneRecallProductListService[1]-queryRecallResult,cost is [{}]", System.currentTimeMillis()-begin);
//3、根据召回结果查询商品信息
... ... @@ -128,7 +128,7 @@ public class SceneRecallProductListService {
//4、获取商品的返回信息
long begin = System.currentTimeMillis();
List<Map<String, Object>> productInfoList = sknInfoResqusetResponseCacheBean.queryProductListBySkn(productSknList,productSknList.size());
List<Map<String, Object>> productInfoList = sknReturnInfoCacheBean.queryProductListBySkn(productSknList,productSknList.size());
RECALL_NEW_LOGGER.info("SceneRecallProductListService[2].queryProductListBySkn,cost is [{}]", System.currentTimeMillis()-begin);
//5、填充召回类型
... ...
package com.yoho.search.recall.scene.beans.builder;
import com.yoho.search.recall.scene.beans.cache.SknBaseInfoCacheBean;
import com.yoho.search.recall.scene.models.req.RecallRequestResponse;
import com.yoho.search.recall.scene.models.req.RecallRequest;
import com.yoho.search.recall.scene.models.req.RecallResponse;
import com.yoho.search.recall.scene.models.common.RecallMergerResult;
import com.yoho.search.recall.scene.beans.strategy.StrategyEnum;
import com.yoho.search.recall.scene.models.req.SknBaseInfoResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
... ... @@ -15,6 +18,9 @@ import java.util.Map;
@Component
public class RecallMergerResultBuilder {
@Autowired
private SknBaseInfoCacheBean sknBaseInfoCacheBean;
/**
* 召回结果构造器
*
... ... @@ -60,7 +66,6 @@ public class RecallMergerResultBuilder {
*/
private List<RecallMergerResult.SknResult> distinctRecallSkn(List<RecallRequestResponse> requestResponses) {
List<RecallMergerResult.SknResult> sknResults = new ArrayList<>();
//1、去重以及处理返回类型
Map<Integer, List<StrategyEnum>> skn2StrategyListMap = new HashMap<>();
for (RecallRequestResponse requestResponse : requestResponses) {
RecallRequest request = requestResponse.getRequest();
... ... @@ -68,14 +73,14 @@ public class RecallMergerResultBuilder {
if (request == null || response == null || response.getSkns() == null) {
continue;
}
for (RecallResponse.RecallSkn recallSkn : response.getSkns()) {
List<StrategyEnum> strategyList = skn2StrategyListMap.get(recallSkn.getSkn());
for (Integer productSkn : response.getSkns()) {
List<StrategyEnum> strategyList = skn2StrategyListMap.get(productSkn);
if (strategyList == null) {
//1、加入返回结果
sknResults.add(new RecallMergerResult.SknResult(recallSkn));
sknResults.add(new RecallMergerResult.SknResult(productSkn));
//2、处理返回类型
strategyList = new ArrayList<>();
skn2StrategyListMap.put(recallSkn.getSkn(), strategyList);
skn2StrategyListMap.put(productSkn, strategyList);
}
strategyList.add(request.requestStrategy());
}
... ...
... ... @@ -5,12 +5,13 @@ import com.yoho.search.core.personalized.PersonalizedSearch;
import com.yoho.search.core.personalized.models.SortPriceAreas;
import com.yoho.search.recall.performance.beans.ProductFeatureFactorHepler;
import com.yoho.search.recall.performance.model.UserFeatureFactor;
import com.yoho.search.recall.scene.beans.cache.SknVectorResquestResponseCacheBean;
import com.yoho.search.recall.scene.beans.cache.SknBaseInfoCacheBean;
import com.yoho.search.recall.scene.beans.strategy.StrategyEnum;
import com.yoho.search.recall.scene.constants.SknCountConstants;
import com.yoho.search.recall.scene.models.common.RecallMergerResult;
import com.yoho.search.recall.scene.models.common.RecallSknInfo;
import com.yoho.search.recall.scene.models.personal.UserPersonalFactor;
import com.yoho.search.recall.scene.models.req.SknBaseInfoResponse;
import com.yoho.search.recall.scene.models.req.UserRecallRequest;
import com.yoho.search.recall.scene.models.req.UserRecallResponse;
import com.yoho.search.service.base.ProductListSortKey;
... ... @@ -37,7 +38,7 @@ public class UserRecallResponseBuilder {
@Autowired
private ProductFeatureFactorHepler productFeatureFactorHepler;
@Autowired
private SknVectorResquestResponseCacheBean sknVectorResquestResponseCacheBean;
private SknBaseInfoCacheBean sknBaseInfoCacheBean;
@Autowired
private SearchDynamicConfigService searchDynamicConfigService;
... ... @@ -47,20 +48,19 @@ public class UserRecallResponseBuilder {
//2、获取召回结果中的所有skn
List<RecallMergerResult.SknResult> sknResultList = recallMergerResult.getSknList();
RECALL_NEW_LOGGER.info("total recall skn count after merger is [{}]", sknResultList.size());
//3、填充是否满足品类价格带的过滤
sknResultList = this.fillIsLikePriceArea(sknResultList, userPersonalFactor);
//3、填充skn基本信息
sknResultList = this.fillBaseInfo(sknResultList);
//4、填充skn向量
sknResultList = this.fillProductFactors(sknResultList);
//4、填充是否满足品类价格带的过滤
sknResultList = this.fillIsLikePriceArea(sknResultList, userPersonalFactor);
//5、按相关性计算得分
sknResultList = this.doCalScoreAndSort(sknResultList, userRecallRequest.getUid());
//6、品牌品类平衡
if(searchDynamicConfigService.searchPersionalNewStrategySortBrandBalance()){
if (searchDynamicConfigService.searchPersionalNewStrategySortBrandBalance()) {
sknResultList = this.doBalance(sknResultList);
}
... ... @@ -70,7 +70,7 @@ public class UserRecallResponseBuilder {
//8、策略优先级排序并添加日志
for (RecallMergerResult.SknResult sknResult : sknResultList) {
Collections.sort(sknResult.getStrategys(), (o1, o2) -> o2.getPriority().compareTo(o1.getPriority()));
this.logSknStrategyAndScore(userRecallRequest,sknResult);
this.logSknStrategyAndScore(userRecallRequest, sknResult);
}
//9、分页处理
... ... @@ -92,8 +92,30 @@ public class UserRecallResponseBuilder {
return new UserRecallResponse(total, recallTotal, recallTotalPage, sknList);
}
private void logSknStrategyAndScore(UserRecallRequest userRecallRequest,RecallMergerResult.SknResult sknResult){
if(!userRecallRequest.openDetailLog()){
private List<RecallMergerResult.SknResult> fillBaseInfo(List<RecallMergerResult.SknResult> sknResultList) {
//1、请求构造
List<Integer> productSknList = new ArrayList<>();
for (RecallMergerResult.SknResult sknResult : sknResultList) {
productSknList.add(sknResult.getProductSkn());
}
//2、查询基本信息
Map<Integer, SknBaseInfoResponse> sknBaseInfoMap = sknBaseInfoCacheBean.querySknBaseInfo(productSknList);
//3、填充信息
for (RecallMergerResult.SknResult sknResult : sknResultList) {
SknBaseInfoResponse sknBaseInfo = sknBaseInfoMap.get(sknResult.getProductSkn());
if (sknBaseInfo == null) {
continue;
}
sknResult.setBySknBaseInfo(sknBaseInfo);
}
return sknResultList;
}
private void logSknStrategyAndScore(UserRecallRequest userRecallRequest, RecallMergerResult.SknResult sknResult) {
if (!userRecallRequest.openDetailLog()) {
return;
}
try {
... ... @@ -113,8 +135,8 @@ public class UserRecallResponseBuilder {
//1、获取用户价格带偏好
Map<Integer, List<Integer>> userMisort2PriceAreasMap = new HashMap<>();
List<SortPriceAreas> userSortPriceAreasList = userPersonalFactor.getSortPriceAreasList();
for (SortPriceAreas userSortPriceAreas: userSortPriceAreasList) {
userMisort2PriceAreasMap.put(userSortPriceAreas.getMisort(),userSortPriceAreas.getPriceAreas());
for (SortPriceAreas userSortPriceAreas : userSortPriceAreasList) {
userMisort2PriceAreasMap.put(userSortPriceAreas.getMisort(), userSortPriceAreas.getPriceAreas());
}
//2、填充当前skn是否属于用户偏好的价格带
for (RecallMergerResult.SknResult sknResult : sknResults) {
... ... @@ -129,26 +151,6 @@ public class UserRecallResponseBuilder {
return sknResults;
}
/**
* 查询skn的向量
*
* @param sknResults
* @return
*/
private List<RecallMergerResult.SknResult> fillProductFactors(List<RecallMergerResult.SknResult> sknResults) {
//1、请求构造
List<Integer> skns = new ArrayList<>();
for (RecallMergerResult.SknResult sknResult : sknResults) {
skns.add(sknResult.getProductSkn());
}
//2、执行查询
Map<Integer, String> productFactors = sknVectorResquestResponseCacheBean.querySknVectors(skns);
//3、填充向量
for (RecallMergerResult.SknResult sknResult : sknResults) {
sknResult.setFactor(MapUtils.getString(productFactors, sknResult.getProductSkn(), ""));
}
return sknResults;
}
/**
* 粗排-按相关性计算得分,并按得分排序
... ... @@ -186,6 +188,7 @@ public class UserRecallResponseBuilder {
/**
* 当前商品是否只是兜底策略找回来的
*
* @param sknResult
* @return
*/
... ... @@ -196,7 +199,7 @@ public class UserRecallResponseBuilder {
return true;
}
//2、只是兜底策略
if(strategys.size()==1 &&strategys.get(0).equals(StrategyEnum.COMMON) ){
if (strategys.size() == 1 && strategys.get(0).equals(StrategyEnum.COMMON)) {
return true;
}
return false;
... ...
... ... @@ -4,7 +4,6 @@ import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.core.es.model.SearchResult;
import com.yoho.search.recall.scene.beans.helper.RecallResponseHelper;
import com.yoho.search.recall.scene.models.req.RecallRequestResponse;
import com.yoho.search.recall.scene.models.req.RecallRequest;
import com.yoho.search.recall.scene.models.req.RecallResponse;
... ... @@ -19,12 +18,10 @@ import java.util.List;
import java.util.Map;
@Component
public class RecallRequestResponseCacheBean extends AbstractCacheBean<RecallRequest,RecallResponse,RecallRequestResponse> {
public class BatchRecallCacheBean extends AbstractCacheBean<RecallRequest,RecallResponse,RecallRequestResponse> {
@Autowired
private SearchCommonService searchCommonService;
@Autowired
private SknVectorResquestResponseCacheBean sknVectorResquestResponseCacheBean;
/**
* 批量召回入口
... ... @@ -72,19 +69,13 @@ public class RecallRequestResponseCacheBean extends AbstractCacheBean<RecallRequ
private RecallResponse buildResonse(SearchResult searchResult) {
List<Map<String, Object>> productList = searchResult.getResultList();
List<RecallResponse.RecallSkn> recallSknList = new ArrayList<>();
Map<Integer,String> productFactorMap = new HashMap<>();
List<Integer> recallSknList = new ArrayList<>();
//1、构建结果
for (Map<String, Object> productInfo : productList) {
RecallResponse.RecallSkn recallSkn = RecallResponseHelper.buildRecallSkn(productInfo);
recallSknList.add(recallSkn);
Integer productSkn = MapUtils.getInteger(productInfo, ProductIndexEsField.productSkn, 0);
String factor = MapUtils.getString(productInfo, ProductIndexEsField.productFeatureFactor, "");
productFactorMap.put(productSkn,factor);
recallSknList.add(productSkn);
}
//2、将skn向量加入缓存-可节省一次ES查询
sknVectorResquestResponseCacheBean.batchAddSknVectorsToCache(productFactorMap);
return RecallResponseHelper.buildRecallResponse(recallSknList,searchResult.getTotal());
return new RecallResponse(searchResult.getTotal(),recallSknList);
}
}
... ...
package com.yoho.search.recall.scene.beans.cache;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.core.es.model.SearchResult;
import com.yoho.search.recall.scene.beans.helper.RecallResponseHelper;
import com.yoho.search.recall.scene.beans.strategy.impls.RecommendProductStrategy;
import com.yoho.search.recall.scene.models.common.IRecallRequest;
import com.yoho.search.recall.scene.models.req.*;
import com.yoho.search.service.base.SearchCommonService;
import org.apache.commons.collections.MapUtils;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.*;
@Component
public class RecommendProductRecallCacheBean extends AbstractCacheBean<RecommendProductRequest, RecallResponse, RecommendProductRequestResponse> {
@Autowired
private SearchCommonService searchCommonService;
/**
* 按productId召回的入口
* @param productIds
* @return
*/
public List<RecallRequestResponse> batchRecallAndCache(List<Integer> productIds) {
//1、参数判断
if(productIds==null || productIds.isEmpty()){
return new ArrayList<>();
}
//2、执行查询
List<RecommendProductRequestResponse> responses = this.batchQuery(productIds);
//3、数据转换
List<RecallRequestResponse> results = new ArrayList<>();
for (RecommendProductRequestResponse recommendProductRequestResponse: responses){
RecommendProductRequest request = recommendProductRequestResponse.getRequest();
RecallResponse response = recommendProductRequestResponse.getResponse();
if(request==null || response==null){
continue;
}
Integer productId = request.getProductId();
RecallRequest recallRequest = new RecallRequest(new RecommendProductStrategy(productId));
results.add(new RecallRequestResponse(recallRequest,response));
}
return results;
}
private List<RecommendProductRequestResponse> batchQuery(List<Integer> productIds){
//1、构造结果
final List<RecommendProductRequestResponse> results = new ArrayList<>();
for (Integer productId : productIds) {
results.add(new RecommendProductRequestResponse(new RecommendProductRequest(productId)));
}
//2、调父类方法
super.bacthFillResponseWithCache(results,productIds.size());
//3、返回结果
return results;
}
public void batchAddProductRecallInfoToCache(Map<Integer,RecallResponse> productVectors){
List<RecommendProductRequestResponse> results = new ArrayList<>();
for (Map.Entry<Integer,RecallResponse> entry: productVectors.entrySet()) {
RecommendProductRequestResponse result = new RecommendProductRequestResponse(new RecommendProductRequest(entry.getKey()));
result.setResponse(entry.getValue(),true);
results.add(result);
}
super.batchAddResponseToCache(results);
}
@Override
protected boolean useEhCache() {
return false;
}
@Override
protected Map<RecommendProductRequest, RecallResponse> queryMissCacheRequestResults(List<RecommendProductRequestResponse> missCacheRequests) {
//1、合法性判断
Map<RecommendProductRequest,RecallResponse> results = new HashMap<>();
if(missCacheRequests==null||missCacheRequests.isEmpty()){
return results;
}
//2、获取productId
List<Integer> productIds = new ArrayList<>();
for (RecommendProductRequestResponse recommendProductRequestResponse : missCacheRequests) {
productIds.add(recommendProductRequestResponse.getRequest().getProductId());
}
//3、构建SearchParam并查询
SearchParam searchParam = new SearchParam();
searchParam.setOffset(0);
searchParam.setSize(productIds.size());
searchParam.setFiter(QueryBuilders.termsQuery(ProductIndexEsField.productId, productIds));
searchParam.setIncludeFields( missCacheRequests.get(0).getRequest().includeFields());
SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_PRODUCT_INDEX, searchParam);
//4、构建基于ProductId的临时结果
Map<Integer,RecallResponse> productTempMap = new HashMap<>();
for (Map<String, Object> productInfo: searchResult.getResultList()){
Integer productId = MapUtils.getIntValue(productInfo,ProductIndexEsField.productId,0);
RecallResponse.RecallSkn recallSkn = RecallResponseHelper.buildRecallSkn(productInfo);
RecallResponse recallResponse = RecallResponseHelper.buildRecallResponse(recallSkn);
productTempMap.put(productId,recallResponse);
}
//5、构造最终结果
for (RecommendProductRequestResponse recommendProductRequestResponse :missCacheRequests ) {
results.put(recommendProductRequestResponse.getRequest(),productTempMap.get(recommendProductRequestResponse.getRequest().getProductId()));
}
return results;
}
}
package com.yoho.search.recall.scene.beans.cache;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.core.es.model.SearchResult;
import com.yoho.search.recall.scene.models.req.*;
import com.yoho.search.service.base.SearchCommonService;
import org.apache.commons.collections.MapUtils;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.*;
@Component
public class SknBaseInfoCacheBean extends AbstractCacheBean<SknBaseInfoRequest, SknBaseInfoResponse, SknBaseInfoRequestResponse> {
@Autowired
private SearchCommonService searchCommonService;
/**
* 查询skn对应的productId
*
* @param productSknList
* @return
*/
public Map<Integer, Integer> queryProductSknToProductIdMap(List<Integer> productSknList) {
//1、参数判断
if (productSknList == null || productSknList.isEmpty()) {
return new HashMap<>();
}
//2、执行查询
List<SknBaseInfoRequestResponse> baseInfoList = this.batchQuery(productSknList);
//3、构造结果
Map<Integer, Integer> results = new HashMap<>();
for (SknBaseInfoRequestResponse requestResponse: baseInfoList) {
SknBaseInfoResponse response = requestResponse.getResponse();
if(response==null){
continue;
}
results.put(response.getProductSkn(),response.getProductId());
}
return results;
}
/**
* 查询skn对应的productId
*
* @param productSknList
* @return
*/
public Map<Integer, String> queryProductVectorMap(List<Integer> productSknList) {
//1、参数判断
if (productSknList == null || productSknList.isEmpty()) {
return new HashMap<>();
}
//2、执行查询
List<SknBaseInfoRequestResponse> baseInfoList = this.batchQuery(productSknList);
//3、构造结果
Map<Integer, String> results = new HashMap<>();
for (SknBaseInfoRequestResponse requestResponse: baseInfoList) {
SknBaseInfoResponse response = requestResponse.getResponse();
if(response==null){
continue;
}
results.put(response.getProductSkn(),response.getProductFeatureFactor());
}
return results;
}
/**
* 查询skn对应的productId
*
* @param productSknList
* @return
*/
public Map<Integer, SknBaseInfoResponse> querySknBaseInfo(List<Integer> productSknList) {
//1、参数判断
if (productSknList == null || productSknList.isEmpty()) {
return new HashMap<>();
}
//2、执行查询
List<SknBaseInfoRequestResponse> baseInfoList = this.batchQuery(productSknList);
//3、构造结果
Map<Integer, SknBaseInfoResponse> results = new HashMap<>();
for (SknBaseInfoRequestResponse requestResponse: baseInfoList) {
SknBaseInfoResponse response = requestResponse.getResponse();
if(response==null){
continue;
}
results.put(response.getProductSkn(),response);
}
return results;
}
private List<SknBaseInfoRequestResponse> batchQuery(List<Integer> productSknList) {
//1、参数判断
if (productSknList == null || productSknList.isEmpty()) {
return new ArrayList<>();
}
//2、构造请求
final List<SknBaseInfoRequestResponse> requestResponses = new ArrayList<>();
for (Integer productSkn : productSknList) {
requestResponses.add(new SknBaseInfoRequestResponse(new SknBaseInfoRequest(productSkn)));
}
//2、调父类方法
super.bacthFillResponseWithCache(requestResponses, productSknList.size());
return requestResponses;
}
@Override
protected boolean useEhCache() {
return false;
}
@Override
protected Map<SknBaseInfoRequest, SknBaseInfoResponse> queryMissCacheRequestResults(List<SknBaseInfoRequestResponse> missCacheRequests) {
//1、合法性判断
Map<SknBaseInfoRequest, SknBaseInfoResponse> results = new HashMap<>();
if (missCacheRequests == null || missCacheRequests.isEmpty()) {
return results;
}
//2、获取productId
List<Integer> productSkns = new ArrayList<>();
for (SknBaseInfoRequestResponse sknBaseInfoRequestResponse : missCacheRequests) {
productSkns.add(sknBaseInfoRequestResponse.getRequest().getProductSkn());
}
//3、构建SearchParam并查询
SearchParam searchParam = new SearchParam();
searchParam.setOffset(0);
searchParam.setSize(productSkns.size());
searchParam.setFiter(QueryBuilders.termsQuery(ProductIndexEsField.productSkn, productSkns));
searchParam.setIncludeFields(missCacheRequests.get(0).getRequest().includeFields());
SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_PRODUCT_INDEX, searchParam);
//4、构建基于ProductId的临时结果
Map<Integer, SknBaseInfoResponse> productTempMap = new HashMap<>();
for (Map<String, Object> productInfo : searchResult.getResultList()) {
Integer productId = MapUtils.getIntValue(productInfo, ProductIndexEsField.productId, 0);
Integer productSkn = MapUtils.getInteger(productInfo, ProductIndexEsField.productSkn, 0);
Integer brandId = MapUtils.getInteger(productInfo, ProductIndexEsField.brandId, 0);
Integer middleSortId = MapUtils.getInteger(productInfo, ProductIndexEsField.middleSortId, 0);
Integer priceArea = MapUtils.getInteger(productInfo, ProductIndexEsField.priceArea, 0);
String productFeatureFactor = MapUtils.getString(productInfo, ProductIndexEsField.productFeatureFactor, "");
SknBaseInfoResponse sknBaseInfo = new SknBaseInfoResponse(productId,productSkn,brandId,middleSortId,priceArea,productFeatureFactor);
productTempMap.put(productSkn, sknBaseInfo);
}
//5、构造最终结果
for (SknBaseInfoRequestResponse sknBaseInfoRequestResponse : missCacheRequests) {
results.put(sknBaseInfoRequestResponse.getRequest(), productTempMap.get(sknBaseInfoRequestResponse.getRequest().getProductSkn()));
}
return results;
}
}
... ...
... ... @@ -5,8 +5,8 @@ import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.core.es.model.SearchResult;
import com.yoho.search.recall.scene.models.req.SknInfoResqusetResponse;
import com.yoho.search.recall.scene.models.req.SknInfoResquest;
import com.yoho.search.recall.scene.models.req.SknReturnInfoResqusetResponse;
import com.yoho.search.recall.scene.models.req.SknReturnInfoResquest;
import com.yoho.search.service.base.SearchCommonService;
import com.yoho.search.service.base.index.ProductIndexBaseService;
import org.apache.commons.collections.MapUtils;
... ... @@ -20,7 +20,7 @@ import java.util.List;
import java.util.Map;
@Component
public class SknInfoResqusetResponseCacheBean extends AbstractCacheBean<SknInfoResquest,Map<String, Object>,SknInfoResqusetResponse> {
public class SknReturnInfoCacheBean extends AbstractCacheBean<SknReturnInfoResquest,Map<String, Object>,SknReturnInfoResqusetResponse> {
@Autowired
private SearchCommonService searchCommonService;
... ... @@ -35,10 +35,10 @@ public class SknInfoResqusetResponseCacheBean extends AbstractCacheBean<SknInfoR
*/
public List<Map<String, Object>> queryProductListBySkn(List<Integer> productSkns,int size){
//1、批量查询SKN信息
List<SknInfoResqusetResponse> sknInfoCacheRequestRespons = this.batchQuery(productSkns);
List<SknReturnInfoResqusetResponse> sknInfoCacheRequestRespons = this.batchQuery(productSkns);
//2、构造返回结果
List<Map<String, Object>> finalResults = new ArrayList<>();
for (SknInfoResqusetResponse sknInfoCacheRequestResponse : sknInfoCacheRequestRespons) {
for (SknReturnInfoResqusetResponse sknInfoCacheRequestResponse : sknInfoCacheRequestRespons) {
if(sknInfoCacheRequestResponse !=null && sknInfoCacheRequestResponse.getResponse()!=null){
finalResults.add(sknInfoCacheRequestResponse.getResponse());
}
... ... @@ -49,11 +49,11 @@ public class SknInfoResqusetResponseCacheBean extends AbstractCacheBean<SknInfoR
return finalResults;
}
private List<SknInfoResqusetResponse> batchQuery(List<Integer> productSkns){
private List<SknReturnInfoResqusetResponse> batchQuery(List<Integer> productSkns){
//1、构建请求与返回结果
final List<SknInfoResqusetResponse> requests = new ArrayList<>();
final List<SknReturnInfoResqusetResponse> requests = new ArrayList<>();
for (Integer productSkn : productSkns) {
requests.add(new SknInfoResqusetResponse(new SknInfoResquest(productSkn)));
requests.add(new SknReturnInfoResqusetResponse(new SknReturnInfoResquest(productSkn)));
}
//2、调父类方法
this.bacthFillResponseWithCache(requests,productSkns.size());
... ... @@ -68,15 +68,15 @@ public class SknInfoResqusetResponseCacheBean extends AbstractCacheBean<SknInfoR
}
@Override
protected Map<SknInfoResquest, Map<String, Object>> queryMissCacheRequestResults(List<SknInfoResqusetResponse> missCacheRequests) {
protected Map<SknReturnInfoResquest, Map<String, Object>> queryMissCacheRequestResults(List<SknReturnInfoResqusetResponse> missCacheRequests) {
//1、合法性判断
Map<SknInfoResquest,Map<String, Object>> results = new HashMap<>();
Map<SknReturnInfoResquest,Map<String, Object>> results = new HashMap<>();
if(missCacheRequests==null||missCacheRequests.isEmpty()){
return results;
}
//2、获取skn
List<Integer> productSkns = new ArrayList<>();
for (SknInfoResqusetResponse sknInfoCacheRequestResponse : missCacheRequests) {
for (SknReturnInfoResqusetResponse sknInfoCacheRequestResponse : missCacheRequests) {
productSkns.add(sknInfoCacheRequestResponse.getRequest().getProductSkn());
}
//3、构建SearchParam
... ... @@ -93,7 +93,7 @@ public class SknInfoResqusetResponseCacheBean extends AbstractCacheBean<SknInfoR
productTempMap.put(MapUtils.getIntValue(product,"product_skn",0),product);
}
//5、构造最终结果
for (SknInfoResqusetResponse requestResponse :missCacheRequests ) {
for (SknReturnInfoResqusetResponse requestResponse :missCacheRequests ) {
results.put(requestResponse.getRequest(),productTempMap.get(requestResponse.getRequest().getProductSkn()));
}
return results;
... ...
package com.yoho.search.recall.scene.beans.cache;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.core.es.model.SearchResult;
import com.yoho.search.recall.scene.models.req.SknVectorResquestResponse;
import com.yoho.search.recall.scene.models.req.SknVectorResquest;
import com.yoho.search.service.base.SearchCommonService;
import org.apache.commons.collections.MapUtils;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.*;
@Component
public class SknVectorResquestResponseCacheBean extends AbstractCacheBean<SknVectorResquest,String,SknVectorResquestResponse> {
@Autowired
private SearchCommonService searchCommonService;
/**
* 查询商品向量
* @param skns
* @return
*/
public Map<Integer,String> querySknVectors(List<Integer> skns){
//1、构造请求参数
List<SknVectorResquestResponse> results = new ArrayList<>();
for (Integer productSkn:skns) {
results.add(new SknVectorResquestResponse(new SknVectorResquest(productSkn)));
}
//2、调父类方法填充结果
this.bacthFillResponseWithCache(results,skns.size());
//3、构造返回结果
Map<Integer,String> sknVectorMap = new HashMap<>();
for (SknVectorResquestResponse sknVectorResquestResponse :results) {
sknVectorMap.put(sknVectorResquestResponse.getRequest().getProductSkn(), sknVectorResquestResponse.getResponse());
}
return sknVectorMap;
}
public void batchAddSknVectorsToCache(Map<Integer,String> productVectors){
List<SknVectorResquestResponse> results = new ArrayList<>();
for (Map.Entry<Integer,String> entry: productVectors.entrySet()) {
SknVectorResquestResponse result = new SknVectorResquestResponse(new SknVectorResquest(entry.getKey()));
result.setResponse(entry.getValue(),true);
results.add(result);
}
super.batchAddResponseToCache(results);
}
@Override
protected boolean useEhCache() {
return true;
}
@Override
protected Map<SknVectorResquest, String> queryMissCacheRequestResults(List<SknVectorResquestResponse> missCacheRequests) {
//1、合法性判断
Map<SknVectorResquest,String> results = new HashMap<>();
if(missCacheRequests==null||missCacheRequests.isEmpty()){
return results;
}
//2、获取skn
List<Integer> productSkns = new ArrayList<>();
for (SknVectorResquestResponse sknVectorResquestResponse : missCacheRequests) {
productSkns.add(sknVectorResquestResponse.getRequest().getProductSkn());
}
//3、构建SearchParam
SearchParam searchParam = new SearchParam();
searchParam.setOffset(0);
searchParam.setSize(productSkns.size());
searchParam.setFiter(QueryBuilders.termsQuery(ProductIndexEsField.productSkn, productSkns));
searchParam.setIncludeFields(Arrays.asList(ProductIndexEsField.productSkn,ProductIndexEsField.productFeatureFactor));
SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_PRODUCT_INDEX, searchParam);
//4、构建SKN临时结果
Map<Integer,String> productTempMap = new HashMap<>();
for (Map<String, Object> product: searchResult.getResultList()){
Integer productSkn = MapUtils.getIntValue(product,ProductIndexEsField.productSkn,0);
String factor = MapUtils.getString(product,ProductIndexEsField.productFeatureFactor,"");
productTempMap.put(productSkn,factor);
}
//5、构造最终结果
for (SknVectorResquestResponse requestResponse :missCacheRequests ) {
results.put(requestResponse.getRequest(),productTempMap.get(requestResponse.getRequest().getProductSkn()));
}
return results;
}
}
... ... @@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
import java.util.*;
@Component
public class UserRecallRequestResponseCacheBean extends AbstractCacheBean<UserRecallRequest, UserRecallResponse, UserRecallRequestResponse> {
public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, UserRecallResponse, UserRecallRequestResponse> {
private static final Logger RECALL_NEW_LOGGER = LoggerFactory.getLogger("RECALL");
... ... @@ -29,9 +29,9 @@ public class UserRecallRequestResponseCacheBean extends AbstractCacheBean<UserRe
@Autowired
private SortBrandRecallRequestBuilder sortBrandRecallRequestBuilder;
@Autowired
private RecallRequestResponseCacheBean recallRequestResponseCacheBean;
private BatchRecallCacheBean batchRecallCacheBean;
@Autowired
private RecommendProductRecallCacheBean recommendProductRecallCacheBean;
private SknBaseInfoCacheBean sknBaseInfoCacheBean;
@Autowired
private RecallMergerResultBuilder recallMergerResultBuilder;
... ... @@ -102,18 +102,18 @@ public class UserRecallRequestResponseCacheBean extends AbstractCacheBean<UserRe
//1、构造批量请求并召回
List<RecallRequest> batchRecallRequests = this.buildBatchRecallRequests(userRecallRequest, userPersonalFactor);
List<RecallRequestResponse> batchRecallRequestResponses = recallRequestResponseCacheBean.batchRecallAndCache(batchRecallRequests);
List<RecallRequestResponse> batchRecallRequestResponses = batchRecallCacheBean.batchRecallAndCache(batchRecallRequests);
RECALL_NEW_LOGGER.info("UserRecallRequestResponseCacheBean[2]-batchRecallRequestResponses,cost is [{}]", System.currentTimeMillis() - begin);
//2、按productId单独召回
begin = System.currentTimeMillis();
List<RecallRequestResponse> recommendProductRequestResponses = recommendProductRecallCacheBean.batchRecallAndCache(userPersonalFactor.getProductIdList());
RECALL_NEW_LOGGER.info("UserRecallRequestResponseCacheBean[2]-batchRecallByProductId,cost is [{}]", System.currentTimeMillis() - begin);
// //2、按productId单独召回
// begin = System.currentTimeMillis();
// List<RecallRequestResponse> recommendProductRequestResponses = sknBaseInfoCacheBean.batchRecallAndCache(userPersonalFactor.getProductIdList());
// RECALL_NEW_LOGGER.info("UserRecallRequestResponseCacheBean[2]-batchRecallByProductId,cost is [{}]", System.currentTimeMillis() - begin);
//4、构造最终返回结果
List<RecallRequestResponse> batchRequestResults = new ArrayList<>();
batchRequestResults.addAll(batchRecallRequestResponses);
batchRequestResults.addAll(recommendProductRequestResponses);
//batchRequestResults.addAll(recommendProductRequestResponses);
//5、日志打印
if (userRecallRequest.openDetailLog()) {
for (RecallRequestResponse recallRequestResponse : batchRequestResults) {
... ...
package com.yoho.search.recall.scene.beans.helper;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.recall.scene.models.req.RecallResponse;
import org.apache.commons.collections.MapUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class RecallResponseHelper {
public static RecallResponse.RecallSkn buildRecallSkn(Map<String, Object> productInfo) {
Integer productSkn = MapUtils.getInteger(productInfo, ProductIndexEsField.productSkn, 0);
Integer brandId = MapUtils.getInteger(productInfo, ProductIndexEsField.brandId, 0);
Integer middleSortId = MapUtils.getInteger(productInfo, ProductIndexEsField.middleSortId, 0);
Integer priceArea = MapUtils.getInteger(productInfo, ProductIndexEsField.priceArea, 0);
return new RecallResponse.RecallSkn(productSkn, brandId, middleSortId,priceArea);
}
public static RecallResponse buildRecallResponse(RecallResponse.RecallSkn recallSkn) {
List<RecallResponse.RecallSkn> recallSknList = new ArrayList<>();
recallSknList.add(recallSkn);
return new RecallResponse(1, recallSknList);
}
public static RecallResponse buildRecallResponse(List<RecallResponse.RecallSkn> recallSknList,long total) {
return new RecallResponse(total, recallSknList);
}
}
package com.yoho.search.recall.scene.beans.strategy.impls;
import com.yoho.search.recall.scene.beans.helper.ExtendFilterHelper;
import com.yoho.search.recall.scene.beans.helper.SortBuilderHelper;
import com.yoho.search.recall.scene.beans.strategy.IStrategy;
import com.yoho.search.recall.scene.beans.strategy.StrategyEnum;
import com.yoho.search.recall.scene.constants.CacheTimeConstants;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.search.sort.SortBuilder;
/**
* 按productId的召回策略
*
* @author gufei.hu
*
*/
public class RecommendProductStrategy implements IStrategy {
private Integer productId;
public RecommendProductStrategy(Integer productId) {
this.productId = productId;
}
@Override
public StrategyEnum strategtEnum() {
return StrategyEnum.RECOMMEND_PRODUCT;
}
@Override
public QueryBuilder extendFilter() {
return ExtendFilterHelper.productIdFilter(this.productId);
}
@Override
public SortBuilder<?> sortBuilder() {
return SortBuilderHelper.getIdDescSort();
}
@Override
public int size() {
return 1;
}
@Override
public int cacheTimeInSecond() {
return CacheTimeConstants.PRODUCTID_TO_RECALL_RESPONSE;
}
@Override
public String strategyCacheKey() {
StringBuilder sb = defaultStrategyKey();
sb.append(this.productId==null?"0":productId.toString());
return sb.toString();
}
}
... ... @@ -12,14 +12,11 @@ public class CacheTimeConstants {
//品类+品牌的缓存 - 60分钟
public static final int SORT_BRAND_RECALL_STRATEGY_CACHE_TIME = 60 * 60;
//productId to response的缓存-一个小时
public static final int PRODUCTID_TO_RECALL_RESPONSE = 60 * 60;
//SKN基本信息的缓存-一个小时
public static final int SKN_BASE_INFO = 60 * 60;
//SKN向量的缓存-一个小时
public static final int SKN_VECTOR = 60 * 60;
//SKN信息的缓存 - 10分钟
public static final int SKN_INFO = 10 * 60;
//SKN返回信息的缓存 - 10分钟
public static final int SKN_RETURN_INFO = 10 * 60;
//用户召回结果的缓存-三分钟
public static final int USER_RECALL_SKN_LIST = 3 * 60;
... ...
... ... @@ -2,6 +2,7 @@ package com.yoho.search.recall.scene.models.common;
import com.yoho.search.recall.scene.beans.strategy.StrategyEnum;
import com.yoho.search.recall.scene.models.req.RecallResponse;
import com.yoho.search.recall.scene.models.req.SknBaseInfoResponse;
import java.util.List;
... ... @@ -29,21 +30,41 @@ public class RecallMergerResult {
public static class SknResult {
private Integer productSkn;
private List<StrategyEnum> strategys;
private Integer brandId;
private Integer middleSortId;
private Integer priceArea;
private List<StrategyEnum> strategys;
private String factor;
private Double score;
private boolean likePriceArea;
public SknResult(RecallResponse.RecallSkn recallSkn) {
this.productSkn = recallSkn.getSkn();
this.brandId = recallSkn.getBdId();
this.middleSortId = recallSkn.getMisId();
this.priceArea = recallSkn.getPa();
public SknResult(Integer productSkn) {
this.productSkn = productSkn;
}
/**************************set*******************************/
public void setBySknBaseInfo(SknBaseInfoResponse sknBaseInfoResponse) {
this.brandId = sknBaseInfoResponse.getBrandId();
this.middleSortId = sknBaseInfoResponse.getMisortId();
this.priceArea = sknBaseInfoResponse.getPriceArea();
this.factor = sknBaseInfoResponse.getProductFeatureFactor();
}
public void setStrategys(List<StrategyEnum> strategys) {
this.strategys = strategys;
}
public void setScore(Double score) {
this.score = score;
}
public void setLikePriceArea(boolean likePriceArea) {
this.likePriceArea = likePriceArea;
}
/**************************get*******************************/
public Integer getProductSkn() {
return productSkn;
}
... ... @@ -64,22 +85,11 @@ public class RecallMergerResult {
return strategys;
}
public void setStrategys(List<StrategyEnum> strategys) {
this.strategys = strategys;
}
public void setScore(Double score) {
this.score = score;
}
public Double getScore() {
return score;
}
public void setFactor(String factor) {
this.factor = factor;
}
public String getFactor() {
return factor;
}
... ... @@ -88,9 +98,6 @@ public class RecallMergerResult {
return likePriceArea;
}
public void setLikePriceArea(boolean likePriceArea) {
this.likePriceArea = likePriceArea;
}
}
}
... ...
... ... @@ -12,13 +12,13 @@ public class RecallResponse implements Serializable {
private static final long serialVersionUID = 1696046903324602621L;
private long total;
private List<RecallSkn> skns;
private List<Integer> skns;
public RecallResponse() {
}
public RecallResponse(long total, List<RecallSkn> skns) {
public RecallResponse(long total, List<Integer> skns) {
this.total = total;
this.skns = skns;
}
... ... @@ -31,64 +31,11 @@ public class RecallResponse implements Serializable {
this.total = total;
}
public List<RecallSkn> getSkns() {
public List<Integer> getSkns() {
return skns;
}
public void setSkns(List<RecallSkn> skns) {
public void setSkns(List<Integer> skns) {
this.skns = skns;
}
public static class RecallSkn implements Serializable {
private static final long serialVersionUID = -1137414378305856170L;
private Integer skn;
private Integer bdId;
private Integer misId;
private Integer pa;
public RecallSkn() {
}
public RecallSkn(Integer productSkn, Integer brandId, Integer middleSortId,Integer priceArea) {
this.skn = productSkn;
this.bdId = brandId;
this.misId = middleSortId;
this.pa = priceArea;
}
public Integer getSkn() {
return skn;
}
public void setSkn(Integer skn) {
this.skn = skn;
}
public Integer getBdId() {
return bdId;
}
public void setBdId(Integer bdId) {
this.bdId = bdId;
}
public Integer getMisId() {
return misId;
}
public void setMisId(Integer misId) {
this.misId = misId;
}
public Integer getPa() {
return pa;
}
public void setPa(Integer pa) {
this.pa = pa;
}
}
}
... ...
package com.yoho.search.recall.scene.models.req;
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.recall.scene.beans.strategy.StrategyEnum;
import com.yoho.search.recall.scene.constants.CacheTimeConstants;
import com.yoho.search.recall.scene.models.common.ICacheRequest;
import com.yoho.search.recall.scene.models.common.IRecallRequest;
import java.util.Arrays;
import java.util.List;
public class RecommendProductRequest implements ICacheRequest,IRecallRequest {
private Integer productId;
public RecommendProductRequest(Integer productId){
this.productId = productId;
}
@Override
public RedisKeyBuilder redisKeyBuilder() {
return RedisKeyBuilder.newInstance().appendFixed("YOHOSEARCH:").appendFixed("RECOMMEND_PRODUCT:").appendVar(cacheTimeInSecond()).appendFixed(":").appendVar(productId);
}
@Override
public int cacheTimeInSecond() {
return CacheTimeConstants.PRODUCTID_TO_RECALL_RESPONSE;
}
public Integer getProductId() {
return productId;
}
@Override
public StrategyEnum requestStrategy() {
return StrategyEnum.RECOMMEND_PRODUCT;
}
@Override
public SearchParam searchParam() {
return null;
}
/**
* 请求返回的字段
* @return
*/
public List<String> includeFields(){
return Arrays.asList(ProductIndexEsField.productId,ProductIndexEsField.productSkn,ProductIndexEsField.brandId,ProductIndexEsField.middleSortId,ProductIndexEsField.productFeatureFactor,ProductIndexEsField.priceArea);
}
}
package com.yoho.search.recall.scene.models.req;
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.recall.scene.constants.CacheTimeConstants;
import com.yoho.search.recall.scene.models.common.ICacheRequest;
public class SknVectorResquest implements ICacheRequest {
import java.util.Arrays;
import java.util.List;
public class SknBaseInfoRequest implements ICacheRequest{
private Integer productSkn;
public SknVectorResquest(Integer productSkn){
public SknBaseInfoRequest(Integer productSkn){
this.productSkn = productSkn;
}
@Override
public RedisKeyBuilder redisKeyBuilder() {
return RedisKeyBuilder.newInstance().appendFixed("YOHOSEARCH:").appendFixed("SKN_VECTOR:").appendVar(cacheTimeInSecond()).appendFixed(":").appendVar(productSkn);
return RedisKeyBuilder.newInstance().appendFixed("YOHOSEARCH:").appendFixed("SKN_BASE_INFO:").appendVar(cacheTimeInSecond()).appendFixed(":").appendVar(productSkn);
}
@Override
public int cacheTimeInSecond() {
return CacheTimeConstants.SKN_VECTOR;
return CacheTimeConstants.SKN_BASE_INFO;
}
public Integer getProductSkn() {
return productSkn;
}
/**
* 请求返回的字段
* @return
*/
public List<String> includeFields(){
return Arrays.asList(ProductIndexEsField.productId,ProductIndexEsField.productSkn,ProductIndexEsField.brandId,ProductIndexEsField.middleSortId,ProductIndexEsField.priceArea,ProductIndexEsField.productFeatureFactor);
}
}
... ...
package com.yoho.search.recall.scene.models.req;
import com.alibaba.fastjson.JSON;
import com.yoho.search.base.utils.Transfer;
import com.yoho.search.recall.scene.models.common.AbstractCacheRequestResponse;
public class RecommendProductRequestResponse extends AbstractCacheRequestResponse<RecommendProductRequest, RecallResponse> {
public class SknBaseInfoRequestResponse extends AbstractCacheRequestResponse<SknBaseInfoRequest, SknBaseInfoResponse> {
public RecommendProductRequestResponse(RecommendProductRequest request) {
public SknBaseInfoRequestResponse(SknBaseInfoRequest request) {
super(request);
}
@Override
public Transfer<String, RecallResponse> getToResponseTransfer() {
return RecallRequestResponse.toResponseTransfer;
public Transfer<String, SknBaseInfoResponse> getToResponseTransfer() {
return (v) -> JSON.parseObject(v, SknBaseInfoResponse.class);
}
@Override
public Transfer<RecallResponse, String> getFromResponseTransfer() {
return RecallRequestResponse.fromResponseTransfer;
public Transfer<SknBaseInfoResponse, String> getFromResponseTransfer() {
return (v) -> JSON.toJSONString(v);
}
}
... ...
package com.yoho.search.recall.scene.models.req;
import java.io.Serializable;
public class SknBaseInfoResponse implements Serializable{
private static final long serialVersionUID = 256085920443240173L;
private Integer productId;
private Integer productSkn;
private Integer brandId;
private Integer misortId;
private Integer priceArea;
private String productFeatureFactor;
public SknBaseInfoResponse() {
}
public SknBaseInfoResponse(Integer productId, Integer productSkn, Integer brandId, Integer misortId, Integer priceArea, String productFeatureFactor) {
this.productId = productId;
this.productSkn = productSkn;
this.brandId = brandId;
this.misortId = misortId;
this.priceArea = priceArea;
this.productFeatureFactor = productFeatureFactor;
}
public Integer getProductSkn() {
return productSkn;
}
public void setProductSkn(Integer productSkn) {
this.productSkn = productSkn;
}
public Integer getProductId() {
return productId;
}
public void setProductId(Integer productId) {
this.productId = productId;
}
public Integer getBrandId() {
return brandId;
}
public void setBrandId(Integer brandId) {
this.brandId = brandId;
}
public Integer getMisortId() {
return misortId;
}
public void setMisortId(Integer misortId) {
this.misortId = misortId;
}
public Integer getPriceArea() {
return priceArea;
}
public void setPriceArea(Integer priceArea) {
this.priceArea = priceArea;
}
public String getProductFeatureFactor() {
return productFeatureFactor;
}
public void setProductFeatureFactor(String productFeatureFactor) {
this.productFeatureFactor = productFeatureFactor;
}
}
... ...
... ... @@ -4,11 +4,11 @@ import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yoho.search.recall.scene.constants.CacheTimeConstants;
import com.yoho.search.recall.scene.models.common.ICacheRequest;
public class SknInfoResquest implements ICacheRequest {
public class SknReturnInfoResquest implements ICacheRequest {
private Integer productSkn;
public SknInfoResquest(Integer productSkn){
public SknReturnInfoResquest(Integer productSkn){
this.productSkn = productSkn;
}
... ... @@ -19,7 +19,7 @@ public class SknInfoResquest implements ICacheRequest {
@Override
public int cacheTimeInSecond() {
return CacheTimeConstants.SKN_INFO;
return CacheTimeConstants.SKN_RETURN_INFO;
}
public Integer getProductSkn() {
... ...
... ... @@ -8,10 +8,10 @@ import com.yoho.search.recall.scene.models.common.AbstractCacheRequestResponse;
import java.util.HashMap;
import java.util.Map;
public class SknInfoResqusetResponse extends AbstractCacheRequestResponse<SknInfoResquest, Map<String, Object>> {
public class SknReturnInfoResqusetResponse extends AbstractCacheRequestResponse<SknReturnInfoResquest, Map<String, Object>> {
public SknInfoResqusetResponse(SknInfoResquest sknInfoResquest) {
super(sknInfoResquest);
public SknReturnInfoResqusetResponse(SknReturnInfoResquest sknReturnInfoResquest) {
super(sknReturnInfoResquest);
}
static Transfer<String, Map<String, Object>> toResponseTransfer = new Transfer<String, Map<String, Object>>() {
... ...
package com.yoho.search.recall.scene.models.req;
import com.yoho.search.base.utils.Transfer;
import com.yoho.search.recall.scene.models.common.AbstractCacheRequestResponse;
public class SknVectorResquestResponse extends AbstractCacheRequestResponse<SknVectorResquest,String> {
public SknVectorResquestResponse(SknVectorResquest sknVectorResquest) {
super(sknVectorResquest);
}
static Transfer<String, String> toResponseTransfer = new Transfer<String,String>() {
@Override
public String transfer(String value) {
return value;
}
};
static Transfer<String, String> fromResponseTransfer = new Transfer<String, String>() {
@Override
public String transfer(String vector) {
return vector;
}
};
@Override
public Transfer<String, String> getToResponseTransfer() {
return toResponseTransfer;
}
@Override
public Transfer<String, String> getFromResponseTransfer() {
return fromResponseTransfer;
}
}