Showing
3 changed files
with
30 additions
and
29 deletions
@@ -17,6 +17,7 @@ import com.yoho.search.recall.scene.models.req.UserRecallRequest; | @@ -17,6 +17,7 @@ import com.yoho.search.recall.scene.models.req.UserRecallRequest; | ||
17 | import com.yoho.search.recall.scene.models.req.UserRecallResponse; | 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.base.SearchDynamicConfigService; | ||
20 | import com.yoho.search.service.helper.SearchCommonHelper; | 21 | import com.yoho.search.service.helper.SearchCommonHelper; |
21 | import org.apache.commons.collections.MapUtils; | 22 | import org.apache.commons.collections.MapUtils; |
22 | import org.elasticsearch.index.query.BoolQueryBuilder; | 23 | import org.elasticsearch.index.query.BoolQueryBuilder; |
@@ -47,6 +48,8 @@ public class SceneRecallProductListService { | @@ -47,6 +48,8 @@ public class SceneRecallProductListService { | ||
47 | private UserRecallRequestResponseCacheBean userRecallRequestResponseCacheBean; | 48 | private UserRecallRequestResponseCacheBean userRecallRequestResponseCacheBean; |
48 | @Autowired | 49 | @Autowired |
49 | private SknInfoResqusetResponseCacheBean sknInfoResqusetResponseCacheBean; | 50 | private SknInfoResqusetResponseCacheBean sknInfoResqusetResponseCacheBean; |
51 | + @Autowired | ||
52 | + private SearchDynamicConfigService searchDynamicConfigService; | ||
50 | 53 | ||
51 | /** | 54 | /** |
52 | * 个性化召回列表入口1 | 55 | * 个性化召回列表入口1 |
@@ -78,15 +81,21 @@ public class SceneRecallProductListService { | @@ -78,15 +81,21 @@ public class SceneRecallProductListService { | ||
78 | * @return | 81 | * @return |
79 | */ | 82 | */ |
80 | public SearchApiResult recallProductList(UserRecallRequest userRecallRequest, int page) { | 83 | public SearchApiResult recallProductList(UserRecallRequest userRecallRequest, int page) { |
81 | - //1、执行召回 | 84 | + //1、判断第一页是要需要查缓存【不查询缓存时,只添加缓存,以保证用户数据的实时性】 |
85 | + boolean ignoreQueryCache = false; | ||
86 | + if(page==1 && !searchDynamicConfigService.searchPersionalNewStrategyFirstPageCacheOpen()){ | ||
87 | + ignoreQueryCache = true; | ||
88 | + } | ||
89 | + | ||
90 | + //2、执行召回 | ||
82 | long begin = System.currentTimeMillis(); | 91 | long begin = System.currentTimeMillis(); |
83 | - boolean ignoreQueryCache = page==1?true:false;//第一页不查缓存,只添加缓存,保证用户数据的实时性 | ||
84 | UserRecallResponse userRecallResponse = userRecallRequestResponseCacheBean.queryRecallResult(userRecallRequest,ignoreQueryCache); | 92 | UserRecallResponse userRecallResponse = userRecallRequestResponseCacheBean.queryRecallResult(userRecallRequest,ignoreQueryCache); |
85 | - | ||
86 | RECALL_NEW_LOGGER.info("RecallProductListService[1]-queryRecallResult,cost is [{}]", System.currentTimeMillis()-begin); | 93 | RECALL_NEW_LOGGER.info("RecallProductListService[1]-queryRecallResult,cost is [{}]", System.currentTimeMillis()-begin); |
87 | - //2、根据召回结果查询商品信息 | 94 | + |
95 | + //3、根据召回结果查询商品信息 | ||
88 | List<Map<String, Object>> productList = this.queryProductList(userRecallRequest, userRecallResponse,page, userRecallRequest.getPageSize()); | 96 | List<Map<String, Object>> productList = this.queryProductList(userRecallRequest, userRecallResponse,page, userRecallRequest.getPageSize()); |
89 | - //3、构造返回结果 | 97 | + |
98 | + //4、构造返回结果 | ||
90 | JSONObject dataMap = new JSONObject(); | 99 | JSONObject dataMap = new JSONObject(); |
91 | dataMap.put("total", userRecallResponse.getTotal()); | 100 | dataMap.put("total", userRecallResponse.getTotal()); |
92 | dataMap.put("page", page); | 101 | dataMap.put("page", page); |
@@ -50,15 +50,6 @@ public class SearchDynamicConfigService { | @@ -50,15 +50,6 @@ public class SearchDynamicConfigService { | ||
50 | return configReader.getBoolean("search.price.plan.open", true); | 50 | return configReader.getBoolean("search.price.plan.open", true); |
51 | } | 51 | } |
52 | 52 | ||
53 | -// /** | ||
54 | -// * 获取个性化搜索特征向量的版本 默认为-1 | ||
55 | -// * | ||
56 | -// * @return | ||
57 | -// */ | ||
58 | -// public String personalizedSearchVersion() { | ||
59 | -// return configReader.getString("search.personalized.feature.version", "-1"); | ||
60 | -// } | ||
61 | - | ||
62 | /** | 53 | /** |
63 | * 频道降分是否打开 | 54 | * 频道降分是否打开 |
64 | * | 55 | * |
@@ -87,15 +78,6 @@ public class SearchDynamicConfigService { | @@ -87,15 +78,6 @@ public class SearchDynamicConfigService { | ||
87 | } | 78 | } |
88 | 79 | ||
89 | /** | 80 | /** |
90 | - * 是否支持从conversion索引获取搜索提示词 | ||
91 | - * | ||
92 | - * @return | ||
93 | - */ | ||
94 | - public boolean isSearchSuggestionFromConversionOpen() { | ||
95 | - return configReader.getBoolean("search.suggestion.tips.conversion.open", true); | ||
96 | - } | ||
97 | - | ||
98 | - /** | ||
99 | * 关于API查看动态参数值 | 81 | * 关于API查看动态参数值 |
100 | */ | 82 | */ |
101 | public String getDynamicParameterValue(String key) { | 83 | public String getDynamicParameterValue(String key) { |
@@ -185,6 +167,15 @@ public class SearchDynamicConfigService { | @@ -185,6 +167,15 @@ public class SearchDynamicConfigService { | ||
185 | } | 167 | } |
186 | 168 | ||
187 | /** | 169 | /** |
170 | + * 新的的召回策略-第一页是否缓存 | ||
171 | + * | ||
172 | + * @return | ||
173 | + */ | ||
174 | + public boolean searchPersionalNewStrategyFirstPageCacheOpen() { | ||
175 | + return configReader.getBoolean("search.persional.newstrategy.first_page_cache.open", false); | ||
176 | + } | ||
177 | + | ||
178 | + /** | ||
188 | * 促销页使用新的的召回策略 | 179 | * 促销页使用新的的召回策略 |
189 | * | 180 | * |
190 | * @return | 181 | * @return |
@@ -35,6 +35,11 @@ search.suggestion.tips.conversion.open=true | @@ -35,6 +35,11 @@ search.suggestion.tips.conversion.open=true | ||
35 | #searchlike.not_in_shop.same_sort_percent | 35 | #searchlike.not_in_shop.same_sort_percent |
36 | search.searchlike.not_in_shop.same_sort_percent=60 | 36 | search.searchlike.not_in_shop.same_sort_percent=60 |
37 | 37 | ||
38 | +#searchlike | ||
39 | +search.searchlike.similarskn=true | ||
40 | +#log | ||
41 | +search.controller.cost.log.open=true | ||
42 | + | ||
38 | #persional | 43 | #persional |
39 | search.degrade.open.personalized=true | 44 | search.degrade.open.personalized=true |
40 | 45 | ||
@@ -46,16 +51,13 @@ search.sortpage.recall.brand.count=30 | @@ -46,16 +51,13 @@ search.sortpage.recall.brand.count=30 | ||
46 | 51 | ||
47 | search.persional.newstrategy.open=true | 52 | search.persional.newstrategy.open=true |
48 | search.persional.newstrategy.promotion.open=true | 53 | search.persional.newstrategy.promotion.open=true |
54 | +search.persional.newstrategy.first_page_cache.open=false | ||
49 | 55 | ||
50 | #rateLimit | 56 | #rateLimit |
51 | search.persional.rateLimit.open=true | 57 | search.persional.rateLimit.open=true |
52 | search.persional.recommend.open=true | 58 | search.persional.recommend.open=true |
53 | 59 | ||
54 | -#searchlike | ||
55 | -search.searchlike.similarskn=true | ||
56 | -#log | ||
57 | -search.controller.cost.log.open=true | ||
58 | - | 60 | +#rateLimit config |
59 | search.persional.rateLimit.brand.productList=200:2 | 61 | search.persional.rateLimit.brand.productList=200:2 |
60 | search.persional.rateLimit.brand.aggregations=100:2 | 62 | search.persional.rateLimit.brand.aggregations=100:2 |
61 | 63 | ||
@@ -94,7 +96,6 @@ search.persional.rateLimit.zq.aggregations=100:2 | @@ -94,7 +96,6 @@ search.persional.rateLimit.zq.aggregations=100:2 | ||
94 | search.persional.rateLimit.group_brands=100:2 | 96 | search.persional.rateLimit.group_brands=100:2 |
95 | search.persional.rateLimit.group_shops=100:2 | 97 | search.persional.rateLimit.group_shops=100:2 |
96 | 98 | ||
97 | - | ||
98 | search.persional.rateLimit.search=100:2 | 99 | search.persional.rateLimit.search=100:2 |
99 | search.persional.rateLimit.productindex.productList=100:2 | 100 | search.persional.rateLimit.productindex.productList=100:2 |
100 | search.persional.rateLimit.productindex.productListWithPhrase=100:2 | 101 | search.persional.rateLimit.productindex.productListWithPhrase=100:2 |
-
Please register or login to post a comment