Showing
9 changed files
with
73 additions
and
73 deletions
@@ -8,13 +8,13 @@ import com.yoho.search.base.utils.Transfer; | @@ -8,13 +8,13 @@ import com.yoho.search.base.utils.Transfer; | ||
8 | import com.yoho.search.core.es.model.SearchParam; | 8 | import com.yoho.search.core.es.model.SearchParam; |
9 | import com.yoho.search.core.es.model.SearchResult; | 9 | import com.yoho.search.core.es.model.SearchResult; |
10 | import com.yoho.search.models.SearchApiResult; | 10 | import com.yoho.search.models.SearchApiResult; |
11 | -import com.yoho.search.recall.scene.beans.builder.RecallParamsBuilder; | 11 | +import com.yoho.search.recall.scene.beans.builder.UserRecallRequestBuilder; |
12 | import com.yoho.search.recall.scene.beans.cache.QueryProductInfoCacheBean; | 12 | import com.yoho.search.recall.scene.beans.cache.QueryProductInfoCacheBean; |
13 | import com.yoho.search.recall.scene.beans.cache.QueryRecallResultCacheBean; | 13 | import com.yoho.search.recall.scene.beans.cache.QueryRecallResultCacheBean; |
14 | import com.yoho.search.recall.scene.beans.helper.SortBuilderHelper; | 14 | import com.yoho.search.recall.scene.beans.helper.SortBuilderHelper; |
15 | import com.yoho.search.recall.scene.beans.strategy.StrategyNameEnum; | 15 | import com.yoho.search.recall.scene.beans.strategy.StrategyNameEnum; |
16 | -import com.yoho.search.recall.scene.models.req.RecallParamsRequest; | ||
17 | -import com.yoho.search.recall.scene.models.req.RecallParamsResponse; | 16 | +import com.yoho.search.recall.scene.models.req.UserRecallRequest; |
17 | +import com.yoho.search.recall.scene.models.req.UserRecallResponse; | ||
18 | import com.yoho.search.recall.scene.models.common.RecallSknInfo; | 18 | import com.yoho.search.recall.scene.models.common.RecallSknInfo; |
19 | import com.yoho.search.service.base.SearchCommonService; | 19 | import com.yoho.search.service.base.SearchCommonService; |
20 | import com.yoho.search.service.helper.SearchCommonHelper; | 20 | import com.yoho.search.service.helper.SearchCommonHelper; |
@@ -38,7 +38,7 @@ public class SceneRecallProductListService { | @@ -38,7 +38,7 @@ public class SceneRecallProductListService { | ||
38 | private static final Logger RECALL_NEW_LOGGER = LoggerFactory.getLogger("RECALL"); | 38 | private static final Logger RECALL_NEW_LOGGER = LoggerFactory.getLogger("RECALL"); |
39 | 39 | ||
40 | @Autowired | 40 | @Autowired |
41 | - private RecallParamsBuilder recallParamsBuilder; | 41 | + private UserRecallRequestBuilder userRecallRequestBuilder; |
42 | @Autowired | 42 | @Autowired |
43 | private SearchCommonHelper searchCommonHelper; | 43 | private SearchCommonHelper searchCommonHelper; |
44 | @Autowired | 44 | @Autowired |
@@ -62,9 +62,9 @@ public class SceneRecallProductListService { | @@ -62,9 +62,9 @@ public class SceneRecallProductListService { | ||
62 | return new SearchApiResult().setCode(400).setMessage("分页参数不合法"); | 62 | return new SearchApiResult().setCode(400).setMessage("分页参数不合法"); |
63 | } | 63 | } |
64 | //2、构造召回相关参数 | 64 | //2、构造召回相关参数 |
65 | - RecallParamsRequest recallParamsRequest = recallParamsBuilder.buildRecallParams(paramMap, pageSize); | 65 | + UserRecallRequest userRecallRequest = userRecallRequestBuilder.buildUserRecallRequest(paramMap, pageSize); |
66 | //3、执行召回 | 66 | //3、执行召回 |
67 | - return this.recallProductList(recallParamsRequest, page); | 67 | + return this.recallProductList(userRecallRequest, page); |
68 | } catch (Exception e) { | 68 | } catch (Exception e) { |
69 | RECALL_NEW_LOGGER.error(e.getMessage(), e); | 69 | RECALL_NEW_LOGGER.error(e.getMessage(), e); |
70 | return new SearchApiResult().setData(null).setCode(500).setMessage("Exception"); | 70 | return new SearchApiResult().setData(null).setCode(500).setMessage("Exception"); |
@@ -73,45 +73,45 @@ public class SceneRecallProductListService { | @@ -73,45 +73,45 @@ public class SceneRecallProductListService { | ||
73 | 73 | ||
74 | /** | 74 | /** |
75 | * 个性化召回列表入口2 | 75 | * 个性化召回列表入口2 |
76 | - * @param recallParamsRequest | 76 | + * @param userRecallRequest |
77 | * @param page | 77 | * @param page |
78 | * @return | 78 | * @return |
79 | */ | 79 | */ |
80 | - public SearchApiResult recallProductList(RecallParamsRequest recallParamsRequest, int page) { | 80 | + public SearchApiResult recallProductList(UserRecallRequest userRecallRequest, int page) { |
81 | //1、执行召回 | 81 | //1、执行召回 |
82 | long begin = System.currentTimeMillis(); | 82 | long begin = System.currentTimeMillis(); |
83 | - RecallParamsResponse recallParamsResponse = queryRecallResultCacheBean.queryRecallResult(recallParamsRequest); | 83 | + UserRecallResponse userRecallResponse = queryRecallResultCacheBean.queryRecallResult(userRecallRequest); |
84 | RECALL_NEW_LOGGER.info("RecallProductListService[1]-queryRecallResult,cost is [{}]", System.currentTimeMillis()-begin); | 84 | RECALL_NEW_LOGGER.info("RecallProductListService[1]-queryRecallResult,cost is [{}]", System.currentTimeMillis()-begin); |
85 | //2、根据召回结果查询商品信息 | 85 | //2、根据召回结果查询商品信息 |
86 | - List<Map<String, Object>> productList = this.queryProductList(recallParamsRequest, recallParamsResponse,page, recallParamsRequest.getPageSize()); | 86 | + List<Map<String, Object>> productList = this.queryProductList(userRecallRequest, userRecallResponse,page, userRecallRequest.getPageSize()); |
87 | //3、构造返回结果 | 87 | //3、构造返回结果 |
88 | JSONObject dataMap = new JSONObject(); | 88 | JSONObject dataMap = new JSONObject(); |
89 | - dataMap.put("total", recallParamsResponse.getTotal()); | 89 | + dataMap.put("total", userRecallResponse.getTotal()); |
90 | dataMap.put("page", page); | 90 | dataMap.put("page", page); |
91 | - dataMap.put("page_size", recallParamsRequest.getPageSize()); | ||
92 | - dataMap.put("page_total", searchCommonHelper.getTotalPage(recallParamsResponse.getTotal(), recallParamsRequest.getPageSize())); | 91 | + dataMap.put("page_size", userRecallRequest.getPageSize()); |
92 | + dataMap.put("page_total", searchCommonHelper.getTotalPage(userRecallResponse.getTotal(), userRecallRequest.getPageSize())); | ||
93 | dataMap.put("product_list", productList); | 93 | dataMap.put("product_list", productList); |
94 | return new SearchApiResult().setData(dataMap); | 94 | return new SearchApiResult().setData(dataMap); |
95 | } | 95 | } |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * 根据召回结果查询商品列表 | 98 | * 根据召回结果查询商品列表 |
99 | - * @param recallParamsRequest | ||
100 | - * @param recallParamsResponse | 99 | + * @param userRecallRequest |
100 | + * @param userRecallResponse | ||
101 | * @param page | 101 | * @param page |
102 | * @param pageSize | 102 | * @param pageSize |
103 | * @return | 103 | * @return |
104 | */ | 104 | */ |
105 | - private List<Map<String, Object>> queryProductList(RecallParamsRequest recallParamsRequest, RecallParamsResponse recallParamsResponse, int page, int pageSize) { | 105 | + private List<Map<String, Object>> queryProductList(UserRecallRequest userRecallRequest, UserRecallResponse userRecallResponse, int page, int pageSize) { |
106 | //1、判断当前页码是否在召回的页码里 | 106 | //1、判断当前页码是否在召回的页码里 |
107 | - int recallTotalPage = recallParamsResponse.getRecallTotalPage(); | 107 | + int recallTotalPage = userRecallResponse.getRecallTotalPage(); |
108 | //2、在召回结果中则直接根据skn去查询 | 108 | //2、在召回结果中则直接根据skn去查询 |
109 | long begin = System.currentTimeMillis(); | 109 | long begin = System.currentTimeMillis(); |
110 | List<RecallSknInfo> recallSknInfos = null; | 110 | List<RecallSknInfo> recallSknInfos = null; |
111 | if(page<=recallTotalPage){ | 111 | if(page<=recallTotalPage){ |
112 | - recallSknInfos = CollectionUtils.safeSubList(recallParamsResponse.getSknList(),(page-1)*pageSize,page*pageSize); | 112 | + recallSknInfos = CollectionUtils.safeSubList(userRecallResponse.getSknList(),(page-1)*pageSize,page*pageSize); |
113 | }else{ | 113 | }else{ |
114 | - recallSknInfos = this.queryProductSknByFilterSkn(recallParamsRequest, recallParamsResponse.getSknList(), page-recallTotalPage, pageSize); | 114 | + recallSknInfos = this.queryProductSknByFilterSkn(userRecallRequest, userRecallResponse.getSknList(), page-recallTotalPage, pageSize); |
115 | } | 115 | } |
116 | RECALL_NEW_LOGGER.info("SceneRecallProductListService[2].getRecallSknInfos,cost is [{}]", System.currentTimeMillis()-begin); | 116 | RECALL_NEW_LOGGER.info("SceneRecallProductListService[2].getRecallSknInfos,cost is [{}]", System.currentTimeMillis()-begin); |
117 | 117 | ||
@@ -149,18 +149,18 @@ public class SceneRecallProductListService { | @@ -149,18 +149,18 @@ public class SceneRecallProductListService { | ||
149 | * @param pageSize | 149 | * @param pageSize |
150 | * @return | 150 | * @return |
151 | */ | 151 | */ |
152 | - private List<RecallSknInfo> queryProductSknByFilterSkn(RecallParamsRequest recallParamsRequest, List<RecallSknInfo> recallSknInfos, int realPage, int pageSize){ | 152 | + private List<RecallSknInfo> queryProductSknByFilterSkn(UserRecallRequest userRecallRequest, List<RecallSknInfo> recallSknInfos, int realPage, int pageSize){ |
153 | long begin = System.currentTimeMillis(); | 153 | long begin = System.currentTimeMillis(); |
154 | SearchParam searchParam = new SearchParam(); | 154 | SearchParam searchParam = new SearchParam(); |
155 | //1、设置query | 155 | //1、设置query |
156 | - searchParam.setQuery(recallParamsRequest.getParamQueryFilter().getParamQuery()); | 156 | + searchParam.setQuery(userRecallRequest.getParamQueryFilter().getParamQuery()); |
157 | 157 | ||
158 | //2、设置filter | 158 | //2、设置filter |
159 | List<Integer> notProductSkns = new ArrayList<>(); | 159 | List<Integer> notProductSkns = new ArrayList<>(); |
160 | for (RecallSknInfo recallSknInfo:recallSknInfos ){ | 160 | for (RecallSknInfo recallSknInfo:recallSknInfos ){ |
161 | notProductSkns.add(recallSknInfo.getProductSkn()); | 161 | notProductSkns.add(recallSknInfo.getProductSkn()); |
162 | } | 162 | } |
163 | - BoolQueryBuilder filter = recallParamsRequest.getParamQueryFilter().getParamFilter(); | 163 | + BoolQueryBuilder filter = userRecallRequest.getParamQueryFilter().getParamFilter(); |
164 | filter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.productSkn,notProductSkns)); | 164 | filter.mustNot(QueryBuilders.termsQuery(ProductIndexEsField.productSkn,notProductSkns)); |
165 | searchParam.setFiter(filter); | 165 | searchParam.setFiter(filter); |
166 | 166 |
1 | package com.yoho.search.recall.scene.beans.builder; | 1 | package com.yoho.search.recall.scene.beans.builder; |
2 | 2 | ||
3 | import com.yoho.search.recall.scene.models.common.ParamQueryFilter; | 3 | import com.yoho.search.recall.scene.models.common.ParamQueryFilter; |
4 | -import com.yoho.search.recall.scene.models.req.RecallParamsRequest; | 4 | +import com.yoho.search.recall.scene.models.req.UserRecallRequest; |
5 | import com.yoho.search.recall.sort.helper.RecallServiceHelper; | 5 | import com.yoho.search.recall.sort.helper.RecallServiceHelper; |
6 | import com.yoho.search.service.helper.SearchServiceHelper; | 6 | import com.yoho.search.service.helper.SearchServiceHelper; |
7 | import org.apache.commons.collections.MapUtils; | 7 | import org.apache.commons.collections.MapUtils; |
@@ -14,7 +14,7 @@ import java.util.List; | @@ -14,7 +14,7 @@ import java.util.List; | ||
14 | import java.util.Map; | 14 | import java.util.Map; |
15 | 15 | ||
16 | @Component | 16 | @Component |
17 | -public class RecallParamsBuilder { | 17 | +public class UserRecallRequestBuilder { |
18 | 18 | ||
19 | @Autowired | 19 | @Autowired |
20 | private SearchServiceHelper searchServiceHelepr; | 20 | private SearchServiceHelper searchServiceHelepr; |
@@ -28,7 +28,7 @@ public class RecallParamsBuilder { | @@ -28,7 +28,7 @@ public class RecallParamsBuilder { | ||
28 | * @return | 28 | * @return |
29 | * @throws Exception | 29 | * @throws Exception |
30 | */ | 30 | */ |
31 | - public RecallParamsRequest buildRecallParams(Map<String, String> paramMap, int pageSize) throws Exception { | 31 | + public UserRecallRequest buildUserRecallRequest(Map<String, String> paramMap, int pageSize) throws Exception { |
32 | //1、获取链接中的query和filter参数 | 32 | //1、获取链接中的query和filter参数 |
33 | QueryBuilder query = searchServiceHelepr.constructQueryBuilder(paramMap); | 33 | QueryBuilder query = searchServiceHelepr.constructQueryBuilder(paramMap); |
34 | BoolQueryBuilder filter = searchServiceHelepr.constructFilterBuilder(paramMap, null); | 34 | BoolQueryBuilder filter = searchServiceHelepr.constructFilterBuilder(paramMap, null); |
@@ -45,7 +45,7 @@ public class RecallParamsBuilder { | @@ -45,7 +45,7 @@ public class RecallParamsBuilder { | ||
45 | * @return | 45 | * @return |
46 | * @throws Exception | 46 | * @throws Exception |
47 | */ | 47 | */ |
48 | - public RecallParamsRequest buildPromotionRecallParams(Map<String, String> paramMap, BoolQueryBuilder promotionMustFilter, int pageSize) throws Exception { | 48 | + public UserRecallRequest buildPromotionRecallParams(Map<String, String> paramMap, BoolQueryBuilder promotionMustFilter, int pageSize) throws Exception { |
49 | //1、获取链接中的query和filter参数 | 49 | //1、获取链接中的query和filter参数 |
50 | QueryBuilder query = searchServiceHelepr.constructQueryBuilder(paramMap); | 50 | QueryBuilder query = searchServiceHelepr.constructQueryBuilder(paramMap); |
51 | BoolQueryBuilder filter = searchServiceHelepr.constructFilterBuilder(paramMap, null); | 51 | BoolQueryBuilder filter = searchServiceHelepr.constructFilterBuilder(paramMap, null); |
@@ -56,14 +56,14 @@ public class RecallParamsBuilder { | @@ -56,14 +56,14 @@ public class RecallParamsBuilder { | ||
56 | return this.innerBuildRecallParams(paramQueryFilter,paramMap,pageSize); | 56 | return this.innerBuildRecallParams(paramQueryFilter,paramMap,pageSize); |
57 | } | 57 | } |
58 | 58 | ||
59 | - private RecallParamsRequest innerBuildRecallParams(ParamQueryFilter paramQueryFilter, Map<String, String> paramMap, int pageSize) { | 59 | + private UserRecallRequest innerBuildRecallParams(ParamQueryFilter paramQueryFilter, Map<String, String> paramMap, int pageSize) { |
60 | //1、获取firstSkn参数 | 60 | //1、获取firstSkn参数 |
61 | List<String> firstProductSkns = recallServiceHelper.getFirstProductSkns(paramMap); | 61 | List<String> firstProductSkns = recallServiceHelper.getFirstProductSkns(paramMap); |
62 | //2、获取uid或udid | 62 | //2、获取uid或udid |
63 | int uid = MapUtils.getIntValue(paramMap, "uid", 0); | 63 | int uid = MapUtils.getIntValue(paramMap, "uid", 0); |
64 | String udid = MapUtils.getString(paramMap, "udid", ""); | 64 | String udid = MapUtils.getString(paramMap, "udid", ""); |
65 | //3、返回召回参数 | 65 | //3、返回召回参数 |
66 | - return new RecallParamsRequest(paramQueryFilter, pageSize, firstProductSkns, uid, udid); | 66 | + return new UserRecallRequest(paramQueryFilter, pageSize, firstProductSkns, uid, udid); |
67 | } | 67 | } |
68 | 68 | ||
69 | } | 69 | } |
@@ -8,8 +8,8 @@ import com.yoho.search.recall.performance.model.UserFeatureFactor; | @@ -8,8 +8,8 @@ import com.yoho.search.recall.performance.model.UserFeatureFactor; | ||
8 | import com.yoho.search.recall.scene.beans.cache.QueryProductVectorInfoCacheBean; | 8 | import com.yoho.search.recall.scene.beans.cache.QueryProductVectorInfoCacheBean; |
9 | import com.yoho.search.recall.scene.beans.strategy.StrategyNameEnum; | 9 | import com.yoho.search.recall.scene.beans.strategy.StrategyNameEnum; |
10 | import com.yoho.search.recall.scene.models.common.RecallMergerResult; | 10 | import com.yoho.search.recall.scene.models.common.RecallMergerResult; |
11 | -import com.yoho.search.recall.scene.models.req.RecallParamsRequest; | ||
12 | -import com.yoho.search.recall.scene.models.req.RecallParamsResponse; | 11 | +import com.yoho.search.recall.scene.models.req.UserRecallRequest; |
12 | +import com.yoho.search.recall.scene.models.req.UserRecallResponse; | ||
13 | import com.yoho.search.recall.scene.models.common.RecallSknInfo; | 13 | import com.yoho.search.recall.scene.models.common.RecallSknInfo; |
14 | import com.yoho.search.service.base.ProductListSortKey; | 14 | import com.yoho.search.service.base.ProductListSortKey; |
15 | import com.yoho.search.service.base.ProductListSortService; | 15 | import com.yoho.search.service.base.ProductListSortService; |
@@ -23,7 +23,7 @@ import org.springframework.stereotype.Component; | @@ -23,7 +23,7 @@ import org.springframework.stereotype.Component; | ||
23 | import java.util.*; | 23 | import java.util.*; |
24 | 24 | ||
25 | @Component | 25 | @Component |
26 | -public class RecallResultBuilder { | 26 | +public class UserRecallResponseBuilder { |
27 | 27 | ||
28 | private static final Logger RECALL_NEW_LOGGER = LoggerFactory.getLogger("RECALL"); | 28 | private static final Logger RECALL_NEW_LOGGER = LoggerFactory.getLogger("RECALL"); |
29 | 29 | ||
@@ -36,7 +36,7 @@ public class RecallResultBuilder { | @@ -36,7 +36,7 @@ public class RecallResultBuilder { | ||
36 | @Autowired | 36 | @Autowired |
37 | private QueryProductVectorInfoCacheBean queryProductVectorInfoCacheBean; | 37 | private QueryProductVectorInfoCacheBean queryProductVectorInfoCacheBean; |
38 | 38 | ||
39 | - public RecallParamsResponse builderRecallResult(RecallMergerResult recallMergerResult, RecallParamsRequest param, UserPersonalFactorRsp userPersonalFactorRsp){ | 39 | + public UserRecallResponse builderRecallResult(RecallMergerResult recallMergerResult, UserRecallRequest param, UserPersonalFactorRsp userPersonalFactorRsp){ |
40 | //1、获取总数 | 40 | //1、获取总数 |
41 | final long total = recallMergerResult.getTotal(); | 41 | final long total = recallMergerResult.getTotal(); |
42 | 42 | ||
@@ -72,7 +72,7 @@ public class RecallResultBuilder { | @@ -72,7 +72,7 @@ public class RecallResultBuilder { | ||
72 | sknList.add(new RecallSknInfo(sknResult.getProductSkn(),sknResult.getRequestType())); | 72 | sknList.add(new RecallSknInfo(sknResult.getProductSkn(),sknResult.getRequestType())); |
73 | } | 73 | } |
74 | int recallTotal = sknResultList.size(); | 74 | int recallTotal = sknResultList.size(); |
75 | - return new RecallParamsResponse(total,recallTotal,recallTotalPage,sknList); | 75 | + return new UserRecallResponse(total,recallTotal,recallTotalPage,sknList); |
76 | } | 76 | } |
77 | 77 | ||
78 | /** | 78 | /** |
@@ -16,7 +16,7 @@ import java.util.List; | @@ -16,7 +16,7 @@ import java.util.List; | ||
16 | import java.util.Map; | 16 | import java.util.Map; |
17 | 17 | ||
18 | @Component | 18 | @Component |
19 | -public class QueryRecallResultCacheBean extends AbstractCacheBean<RecallParamsRequest,RecallParamsResponse,RecallParamsRequestResponse> { | 19 | +public class QueryRecallResultCacheBean extends AbstractCacheBean<UserRecallRequest,UserRecallResponse,UserRecallRequestResponse> { |
20 | 20 | ||
21 | private static final Logger RECALL_NEW_LOGGER = LoggerFactory.getLogger("RECALL"); | 21 | private static final Logger RECALL_NEW_LOGGER = LoggerFactory.getLogger("RECALL"); |
22 | 22 | ||
@@ -33,17 +33,17 @@ public class QueryRecallResultCacheBean extends AbstractCacheBean<RecallParamsRe | @@ -33,17 +33,17 @@ public class QueryRecallResultCacheBean extends AbstractCacheBean<RecallParamsRe | ||
33 | @Autowired | 33 | @Autowired |
34 | private RecallMergerResultBuilder recallMergerResultBuilder; | 34 | private RecallMergerResultBuilder recallMergerResultBuilder; |
35 | @Autowired | 35 | @Autowired |
36 | - private RecallResultBuilder recallResultBuilder; | 36 | + private UserRecallResponseBuilder userRecallResponseBuilder; |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * 召回入口 | 39 | * 召回入口 |
40 | - * @param recallParamsRequest | 40 | + * @param userRecallRequest |
41 | * @return | 41 | * @return |
42 | */ | 42 | */ |
43 | - public RecallParamsResponse queryRecallResult(RecallParamsRequest recallParamsRequest){ | 43 | + public UserRecallResponse queryRecallResult(UserRecallRequest userRecallRequest){ |
44 | //1、构建请求 | 44 | //1、构建请求 |
45 | - List<RecallParamsRequestResponse> requests = new ArrayList<>(); | ||
46 | - requests.add(new RecallParamsRequestResponse(recallParamsRequest)); | 45 | + List<UserRecallRequestResponse> requests = new ArrayList<>(); |
46 | + requests.add(new UserRecallRequestResponse(userRecallRequest)); | ||
47 | 47 | ||
48 | //2、执行父类方法 | 48 | //2、执行父类方法 |
49 | this.bacthFillResponseWithCache(requests,1); | 49 | this.bacthFillResponseWithCache(requests,1); |
@@ -61,10 +61,10 @@ public class QueryRecallResultCacheBean extends AbstractCacheBean<RecallParamsRe | @@ -61,10 +61,10 @@ public class QueryRecallResultCacheBean extends AbstractCacheBean<RecallParamsRe | ||
61 | } | 61 | } |
62 | 62 | ||
63 | @Override | 63 | @Override |
64 | - protected Map<RecallParamsRequest, RecallParamsResponse> queryMissCacheRequestResults(List<RecallParamsRequestResponse> missCachseRequests) { | ||
65 | - Map<RecallParamsRequest, RecallParamsResponse> results = new HashMap<>(); | ||
66 | - for (RecallParamsRequestResponse request: missCachseRequests) { | ||
67 | - RecallParamsResponse response = this.doRealRecall(request.getRequest()); | 64 | + protected Map<UserRecallRequest, UserRecallResponse> queryMissCacheRequestResults(List<UserRecallRequestResponse> missCachseRequests) { |
65 | + Map<UserRecallRequest, UserRecallResponse> results = new HashMap<>(); | ||
66 | + for (UserRecallRequestResponse request: missCachseRequests) { | ||
67 | + UserRecallResponse response = this.doRealRecall(request.getRequest()); | ||
68 | results.put(request.getRequest(),response); | 68 | results.put(request.getRequest(),response); |
69 | } | 69 | } |
70 | return results; | 70 | return results; |
@@ -75,7 +75,7 @@ public class QueryRecallResultCacheBean extends AbstractCacheBean<RecallParamsRe | @@ -75,7 +75,7 @@ public class QueryRecallResultCacheBean extends AbstractCacheBean<RecallParamsRe | ||
75 | * @param param | 75 | * @param param |
76 | * @return | 76 | * @return |
77 | */ | 77 | */ |
78 | - private RecallParamsResponse doRealRecall(RecallParamsRequest param) { | 78 | + private UserRecallResponse doRealRecall(UserRecallRequest param) { |
79 | //1、获取个性化因子 | 79 | //1、获取个性化因子 |
80 | long begin = System.currentTimeMillis(); | 80 | long begin = System.currentTimeMillis(); |
81 | UserPersonalFactorRsp userPersonalFactorRsp = queryUserPersionalFactorBean.queryPersionalFactor(param); | 81 | UserPersonalFactorRsp userPersonalFactorRsp = queryUserPersionalFactorBean.queryPersionalFactor(param); |
@@ -92,9 +92,9 @@ public class QueryRecallResultCacheBean extends AbstractCacheBean<RecallParamsRe | @@ -92,9 +92,9 @@ public class QueryRecallResultCacheBean extends AbstractCacheBean<RecallParamsRe | ||
92 | RECALL_NEW_LOGGER.info("QueryRecallResultCacheBean[3]-buildRecallMergerResult,cost is [{}]", System.currentTimeMillis()-begin); | 92 | RECALL_NEW_LOGGER.info("QueryRecallResultCacheBean[3]-buildRecallMergerResult,cost is [{}]", System.currentTimeMillis()-begin); |
93 | //5、构造真实结果[排序,截取skn] | 93 | //5、构造真实结果[排序,截取skn] |
94 | begin = System.currentTimeMillis(); | 94 | begin = System.currentTimeMillis(); |
95 | - RecallParamsResponse recallParamsResponse = recallResultBuilder.builderRecallResult(recallMergerResult, param, userPersonalFactorRsp); | 95 | + UserRecallResponse userRecallResponse = userRecallResponseBuilder.builderRecallResult(recallMergerResult, param, userPersonalFactorRsp); |
96 | RECALL_NEW_LOGGER.info("QueryRecallResultCacheBean[4]-builderRecallResult,cost is [{}]", System.currentTimeMillis()-begin); | 96 | RECALL_NEW_LOGGER.info("QueryRecallResultCacheBean[4]-builderRecallResult,cost is [{}]", System.currentTimeMillis()-begin); |
97 | - return recallParamsResponse; | 97 | + return userRecallResponse; |
98 | } | 98 | } |
99 | 99 | ||
100 | /** | 100 | /** |
@@ -103,7 +103,7 @@ public class QueryRecallResultCacheBean extends AbstractCacheBean<RecallParamsRe | @@ -103,7 +103,7 @@ public class QueryRecallResultCacheBean extends AbstractCacheBean<RecallParamsRe | ||
103 | * @param userPersonalFactorRsp | 103 | * @param userPersonalFactorRsp |
104 | * @return | 104 | * @return |
105 | */ | 105 | */ |
106 | - private List<RecallRequest> buildBatchRequests(RecallParamsRequest param, UserPersonalFactorRsp userPersonalFactorRsp) { | 106 | + private List<RecallRequest> buildBatchRequests(UserRecallRequest param, UserPersonalFactorRsp userPersonalFactorRsp) { |
107 | //1、构造召回请求 | 107 | //1、构造召回请求 |
108 | List<RecallRequest> allRequests = new ArrayList<>(); | 108 | List<RecallRequest> allRequests = new ArrayList<>(); |
109 | //2、构造非个性化的请求 | 109 | //2、构造非个性化的请求 |
service/src/main/java/com/yoho/search/recall/scene/beans/persional/QueryUserPersionalFactorBean.java
@@ -5,7 +5,7 @@ import com.yoho.search.core.personalized.models.SortPriceArea; | @@ -5,7 +5,7 @@ import com.yoho.search.core.personalized.models.SortPriceArea; | ||
5 | import com.yoho.search.core.personalized.models.UserPersonalFactorRsp; | 5 | import com.yoho.search.core.personalized.models.UserPersonalFactorRsp; |
6 | import com.yoho.search.recall.scene.constants.RecallCommonConstants; | 6 | import com.yoho.search.recall.scene.constants.RecallCommonConstants; |
7 | import com.yoho.search.recall.scene.models.personal.PagePersonalFactor; | 7 | import com.yoho.search.recall.scene.models.personal.PagePersonalFactor; |
8 | -import com.yoho.search.recall.scene.models.req.RecallParamsRequest; | 8 | +import com.yoho.search.recall.scene.models.req.UserRecallRequest; |
9 | import com.yoho.search.recall.scene.models.personal.PageSortPriceArea; | 9 | import com.yoho.search.recall.scene.models.personal.PageSortPriceArea; |
10 | import org.slf4j.Logger; | 10 | import org.slf4j.Logger; |
11 | import org.slf4j.LoggerFactory; | 11 | import org.slf4j.LoggerFactory; |
@@ -29,18 +29,18 @@ public class QueryUserPersionalFactorBean { | @@ -29,18 +29,18 @@ public class QueryUserPersionalFactorBean { | ||
29 | /** | 29 | /** |
30 | * 获取个性化因子 | 30 | * 获取个性化因子 |
31 | * | 31 | * |
32 | - * @param recallParamsRequest | 32 | + * @param userRecallRequest |
33 | * @return | 33 | * @return |
34 | */ | 34 | */ |
35 | - public UserPersonalFactorRsp queryPersionalFactor(RecallParamsRequest recallParamsRequest) { | 35 | + public UserPersonalFactorRsp queryPersionalFactor(UserRecallRequest userRecallRequest) { |
36 | try { | 36 | try { |
37 | //1、获取页面上的个性化因子 | 37 | //1、获取页面上的个性化因子 |
38 | long begin = System.currentTimeMillis(); | 38 | long begin = System.currentTimeMillis(); |
39 | - PagePersonalFactor pageFactor = pageComponent.queryPagePersionalFactor(recallParamsRequest.getParamQueryFilter()); | 39 | + PagePersonalFactor pageFactor = pageComponent.queryPagePersionalFactor(userRecallRequest.getParamQueryFilter()); |
40 | RECALL_NEW_LOGGER.info("queryPagePersionalFactor . cost is[{}]", System.currentTimeMillis() - begin); | 40 | RECALL_NEW_LOGGER.info("queryPagePersionalFactor . cost is[{}]", System.currentTimeMillis() - begin); |
41 | //2、获取用户的个性化因子 | 41 | //2、获取用户的个性化因子 |
42 | begin = System.currentTimeMillis(); | 42 | begin = System.currentTimeMillis(); |
43 | - UserPersonalFactorRsp userFactor = userComponent.queryUserPersionalFactor(recallParamsRequest.getUid(), recallParamsRequest.getUdid()); | 43 | + UserPersonalFactorRsp userFactor = userComponent.queryUserPersionalFactor(userRecallRequest.getUid(), userRecallRequest.getUdid()); |
44 | RECALL_NEW_LOGGER.info("queryUserPersionalFactor . cost is[{}]", System.currentTimeMillis() - begin); | 44 | RECALL_NEW_LOGGER.info("queryUserPersionalFactor . cost is[{}]", System.currentTimeMillis() - begin); |
45 | //3、join获取最终的结果 | 45 | //3、join获取最终的结果 |
46 | begin = System.currentTimeMillis(); | 46 | begin = System.currentTimeMillis(); |
@@ -48,7 +48,7 @@ public class QueryUserPersionalFactorBean { | @@ -48,7 +48,7 @@ public class QueryUserPersionalFactorBean { | ||
48 | List<SortPriceArea> sortPriceAreas = this.getSortPriceAreaWithSort(pageFactor, userFactor); | 48 | List<SortPriceArea> sortPriceAreas = this.getSortPriceAreaWithSort(pageFactor, userFactor); |
49 | //4、构造UserPersonalFactorRsp | 49 | //4、构造UserPersonalFactorRsp |
50 | UserPersonalFactorRsp userPersonalFactorRsp = new UserPersonalFactorRsp(brandIds, sortPriceAreas, userFactor.getVector()); | 50 | UserPersonalFactorRsp userPersonalFactorRsp = new UserPersonalFactorRsp(brandIds, sortPriceAreas, userFactor.getVector()); |
51 | - RECALL_NEW_LOGGER.info("innerJoinFactor . cost is[{}],uid is[{}], data is [{}] ", System.currentTimeMillis() - begin, recallParamsRequest.getUid(), JSON.toJSONString(userPersonalFactorRsp)); | 51 | + RECALL_NEW_LOGGER.info("innerJoinFactor . cost is[{}],uid is[{}], data is [{}] ", System.currentTimeMillis() - begin, userRecallRequest.getUid(), JSON.toJSONString(userPersonalFactorRsp)); |
52 | return userPersonalFactorRsp; | 52 | return userPersonalFactorRsp; |
53 | } catch (Exception e) { | 53 | } catch (Exception e) { |
54 | logger.error(e.getMessage(), e); | 54 | logger.error(e.getMessage(), e); |
@@ -9,7 +9,7 @@ import com.yoho.search.recall.scene.models.common.ICacheRequest; | @@ -9,7 +9,7 @@ import com.yoho.search.recall.scene.models.common.ICacheRequest; | ||
9 | 9 | ||
10 | import java.util.List; | 10 | import java.util.List; |
11 | 11 | ||
12 | -public class RecallParamsRequest implements ICacheRequest { | 12 | +public class UserRecallRequest implements ICacheRequest { |
13 | 13 | ||
14 | private final ParamQueryFilter paramQueryFilter; | 14 | private final ParamQueryFilter paramQueryFilter; |
15 | private final int pageSize; | 15 | private final int pageSize; |
@@ -18,7 +18,7 @@ public class RecallParamsRequest implements ICacheRequest { | @@ -18,7 +18,7 @@ public class RecallParamsRequest implements ICacheRequest { | ||
18 | private final String udid; | 18 | private final String udid; |
19 | private RedisKeyBuilder redisKeyBuilder; | 19 | private RedisKeyBuilder redisKeyBuilder; |
20 | 20 | ||
21 | - public RecallParamsRequest(ParamQueryFilter paramQueryFilter, int pageSize, List<String> firstProductSkns, int uid, String udid) { | 21 | + public UserRecallRequest(ParamQueryFilter paramQueryFilter, int pageSize, List<String> firstProductSkns, int uid, String udid) { |
22 | this.paramQueryFilter = paramQueryFilter; | 22 | this.paramQueryFilter = paramQueryFilter; |
23 | this.firstProductSkns = firstProductSkns; | 23 | this.firstProductSkns = firstProductSkns; |
24 | this.pageSize = pageSize; | 24 | this.pageSize = pageSize; |
@@ -4,33 +4,33 @@ import com.alibaba.fastjson.JSON; | @@ -4,33 +4,33 @@ import com.alibaba.fastjson.JSON; | ||
4 | import com.yoho.search.base.utils.Transfer; | 4 | import com.yoho.search.base.utils.Transfer; |
5 | import com.yoho.search.recall.scene.models.common.AbstractCacheRequestResponse; | 5 | import com.yoho.search.recall.scene.models.common.AbstractCacheRequestResponse; |
6 | 6 | ||
7 | -public class RecallParamsRequestResponse extends AbstractCacheRequestResponse<RecallParamsRequest,RecallParamsResponse> { | 7 | +public class UserRecallRequestResponse extends AbstractCacheRequestResponse<UserRecallRequest,UserRecallResponse> { |
8 | 8 | ||
9 | - public RecallParamsRequestResponse(RecallParamsRequest request) { | 9 | + public UserRecallRequestResponse(UserRecallRequest request) { |
10 | super(request); | 10 | super(request); |
11 | } | 11 | } |
12 | 12 | ||
13 | - private static Transfer<String,RecallParamsResponse> toResponseTransfer = new Transfer<String, RecallParamsResponse>() { | 13 | + private static Transfer<String,UserRecallResponse> toResponseTransfer = new Transfer<String, UserRecallResponse>() { |
14 | @Override | 14 | @Override |
15 | - public RecallParamsResponse transfer(String jsonValue) { | ||
16 | - return JSON.parseObject(jsonValue, RecallParamsResponse.class); | 15 | + public UserRecallResponse transfer(String jsonValue) { |
16 | + return JSON.parseObject(jsonValue, UserRecallResponse.class); | ||
17 | } | 17 | } |
18 | }; | 18 | }; |
19 | 19 | ||
20 | - private static Transfer<RecallParamsResponse,String> fromResponseTransfer = new Transfer<RecallParamsResponse, String>() { | 20 | + private static Transfer<UserRecallResponse,String> fromResponseTransfer = new Transfer<UserRecallResponse, String>() { |
21 | @Override | 21 | @Override |
22 | - public String transfer(RecallParamsResponse recallParamsResponse) { | ||
23 | - return JSON.toJSONString(recallParamsResponse); | 22 | + public String transfer(UserRecallResponse userRecallResponse) { |
23 | + return JSON.toJSONString(userRecallResponse); | ||
24 | } | 24 | } |
25 | }; | 25 | }; |
26 | 26 | ||
27 | @Override | 27 | @Override |
28 | - public Transfer<String, RecallParamsResponse> getToResponseTransfer() { | 28 | + public Transfer<String, UserRecallResponse> getToResponseTransfer() { |
29 | return toResponseTransfer; | 29 | return toResponseTransfer; |
30 | } | 30 | } |
31 | 31 | ||
32 | @Override | 32 | @Override |
33 | - public Transfer<RecallParamsResponse, String> getFromResponseTransfer() { | 33 | + public Transfer<UserRecallResponse, String> getFromResponseTransfer() { |
34 | return fromResponseTransfer; | 34 | return fromResponseTransfer; |
35 | } | 35 | } |
36 | } | 36 | } |
@@ -5,7 +5,7 @@ import com.yoho.search.recall.scene.models.common.RecallSknInfo; | @@ -5,7 +5,7 @@ import com.yoho.search.recall.scene.models.common.RecallSknInfo; | ||
5 | import java.io.Serializable; | 5 | import java.io.Serializable; |
6 | import java.util.List; | 6 | import java.util.List; |
7 | 7 | ||
8 | -public class RecallParamsResponse implements Serializable{ | 8 | +public class UserRecallResponse implements Serializable{ |
9 | 9 | ||
10 | private static final long serialVersionUID = -5692239509936546967L; | 10 | private static final long serialVersionUID = -5692239509936546967L; |
11 | 11 | ||
@@ -14,11 +14,11 @@ public class RecallParamsResponse implements Serializable{ | @@ -14,11 +14,11 @@ public class RecallParamsResponse implements Serializable{ | ||
14 | private int recallTotalPage; | 14 | private int recallTotalPage; |
15 | private List<RecallSknInfo> sknList; | 15 | private List<RecallSknInfo> sknList; |
16 | 16 | ||
17 | - public RecallParamsResponse() { | 17 | + public UserRecallResponse() { |
18 | 18 | ||
19 | } | 19 | } |
20 | 20 | ||
21 | - public RecallParamsResponse(long total, int recallTotal, int recallTotalPage, List<RecallSknInfo> sknList) { | 21 | + public UserRecallResponse(long total, int recallTotal, int recallTotalPage, List<RecallSknInfo> sknList) { |
22 | this.total = total; | 22 | this.total = total; |
23 | this.recallTotal = recallTotal; | 23 | this.recallTotal = recallTotal; |
24 | this.recallTotalPage = recallTotalPage; | 24 | this.recallTotalPage = recallTotalPage; |
@@ -9,8 +9,8 @@ import com.yoho.search.core.es.model.SearchResult; | @@ -9,8 +9,8 @@ import com.yoho.search.core.es.model.SearchResult; | ||
9 | import com.yoho.search.models.PromotionConditions; | 9 | import com.yoho.search.models.PromotionConditions; |
10 | import com.yoho.search.models.SearchApiResult; | 10 | import com.yoho.search.models.SearchApiResult; |
11 | import com.yoho.search.recall.scene.SceneRecallProductListService; | 11 | import com.yoho.search.recall.scene.SceneRecallProductListService; |
12 | -import com.yoho.search.recall.scene.beans.builder.RecallParamsBuilder; | ||
13 | -import com.yoho.search.recall.scene.models.req.RecallParamsRequest; | 12 | +import com.yoho.search.recall.scene.beans.builder.UserRecallRequestBuilder; |
13 | +import com.yoho.search.recall.scene.models.req.UserRecallRequest; | ||
14 | import com.yoho.search.service.base.SearchCacheService; | 14 | import com.yoho.search.service.base.SearchCacheService; |
15 | import com.yoho.search.service.base.SearchCommonService; | 15 | import com.yoho.search.service.base.SearchCommonService; |
16 | import com.yoho.search.service.base.SearchDynamicConfigService; | 16 | import com.yoho.search.service.base.SearchDynamicConfigService; |
@@ -44,7 +44,7 @@ public class PromotionProductListService extends AbstractCacheAbleService { | @@ -44,7 +44,7 @@ public class PromotionProductListService extends AbstractCacheAbleService { | ||
44 | @Autowired | 44 | @Autowired |
45 | private SearchCacheService searchCacheService; | 45 | private SearchCacheService searchCacheService; |
46 | @Autowired | 46 | @Autowired |
47 | - private RecallParamsBuilder recallParamsBuilder; | 47 | + private UserRecallRequestBuilder userRecallRequestBuilder; |
48 | @Autowired | 48 | @Autowired |
49 | private SceneRecallProductListService sceneRecallProductListService; | 49 | private SceneRecallProductListService sceneRecallProductListService; |
50 | @Autowired | 50 | @Autowired |
@@ -78,8 +78,8 @@ public class PromotionProductListService extends AbstractCacheAbleService { | @@ -78,8 +78,8 @@ public class PromotionProductListService extends AbstractCacheAbleService { | ||
78 | 78 | ||
79 | //3、个性化-走召回逻辑 | 79 | //3、个性化-走召回逻辑 |
80 | if (this.goRecallLogic(paramMap)) { | 80 | if (this.goRecallLogic(paramMap)) { |
81 | - RecallParamsRequest promotionRecallParamsRequest = recallParamsBuilder.buildPromotionRecallParams(paramMap, promotionMustFilter, pageSize); | ||
82 | - return sceneRecallProductListService.recallProductList(promotionRecallParamsRequest, page); | 81 | + UserRecallRequest promotionUserRecallRequest = userRecallRequestBuilder.buildPromotionRecallParams(paramMap, promotionMustFilter, pageSize); |
82 | + return sceneRecallProductListService.recallProductList(promotionUserRecallRequest, page); | ||
83 | } | 83 | } |
84 | 84 | ||
85 | //4、走默认逻辑 | 85 | //4、走默认逻辑 |
-
Please register or login to post a comment