Authored by hugufei

添加用户第一页数据是否缓存的开关

... ... @@ -17,6 +17,7 @@ import com.yoho.search.recall.scene.models.req.UserRecallRequest;
import com.yoho.search.recall.scene.models.req.UserRecallResponse;
import com.yoho.search.recall.scene.models.common.RecallSknInfo;
import com.yoho.search.service.base.SearchCommonService;
import com.yoho.search.service.base.SearchDynamicConfigService;
import com.yoho.search.service.helper.SearchCommonHelper;
import org.apache.commons.collections.MapUtils;
import org.elasticsearch.index.query.BoolQueryBuilder;
... ... @@ -47,6 +48,8 @@ public class SceneRecallProductListService {
private UserRecallRequestResponseCacheBean userRecallRequestResponseCacheBean;
@Autowired
private SknInfoResqusetResponseCacheBean sknInfoResqusetResponseCacheBean;
@Autowired
private SearchDynamicConfigService searchDynamicConfigService;
/**
* 个性化召回列表入口1
... ... @@ -78,15 +81,21 @@ public class SceneRecallProductListService {
* @return
*/
public SearchApiResult recallProductList(UserRecallRequest userRecallRequest, int page) {
//1、执行召回
//1、判断第一页是要需要查缓存【不查询缓存时,只添加缓存,以保证用户数据的实时性】
boolean ignoreQueryCache = false;
if(page==1 && !searchDynamicConfigService.searchPersionalNewStrategyFirstPageCacheOpen()){
ignoreQueryCache = true;
}
//2、执行召回
long begin = System.currentTimeMillis();
boolean ignoreQueryCache = page==1?true:false;//第一页不查缓存,只添加缓存,保证用户数据的实时性
UserRecallResponse userRecallResponse = userRecallRequestResponseCacheBean.queryRecallResult(userRecallRequest,ignoreQueryCache);
RECALL_NEW_LOGGER.info("RecallProductListService[1]-queryRecallResult,cost is [{}]", System.currentTimeMillis()-begin);
//2、根据召回结果查询商品信息
//3、根据召回结果查询商品信息
List<Map<String, Object>> productList = this.queryProductList(userRecallRequest, userRecallResponse,page, userRecallRequest.getPageSize());
//3、构造返回结果
//4、构造返回结果
JSONObject dataMap = new JSONObject();
dataMap.put("total", userRecallResponse.getTotal());
dataMap.put("page", page);
... ...
... ... @@ -50,15 +50,6 @@ public class SearchDynamicConfigService {
return configReader.getBoolean("search.price.plan.open", true);
}
// /**
// * 获取个性化搜索特征向量的版本 默认为-1
// *
// * @return
// */
// public String personalizedSearchVersion() {
// return configReader.getString("search.personalized.feature.version", "-1");
// }
/**
* 频道降分是否打开
*
... ... @@ -87,15 +78,6 @@ public class SearchDynamicConfigService {
}
/**
* 是否支持从conversion索引获取搜索提示词
*
* @return
*/
public boolean isSearchSuggestionFromConversionOpen() {
return configReader.getBoolean("search.suggestion.tips.conversion.open", true);
}
/**
* 关于API查看动态参数值
*/
public String getDynamicParameterValue(String key) {
... ... @@ -185,6 +167,15 @@ public class SearchDynamicConfigService {
}
/**
* 新的的召回策略-第一页是否缓存
*
* @return
*/
public boolean searchPersionalNewStrategyFirstPageCacheOpen() {
return configReader.getBoolean("search.persional.newstrategy.first_page_cache.open", false);
}
/**
* 促销页使用新的的召回策略
*
* @return
... ...
... ... @@ -35,6 +35,11 @@ search.suggestion.tips.conversion.open=true
#searchlike.not_in_shop.same_sort_percent
search.searchlike.not_in_shop.same_sort_percent=60
#searchlike
search.searchlike.similarskn=true
#log
search.controller.cost.log.open=true
#persional
search.degrade.open.personalized=true
... ... @@ -46,16 +51,13 @@ search.sortpage.recall.brand.count=30
search.persional.newstrategy.open=true
search.persional.newstrategy.promotion.open=true
search.persional.newstrategy.first_page_cache.open=false
#rateLimit
search.persional.rateLimit.open=true
search.persional.recommend.open=true
#searchlike
search.searchlike.similarskn=true
#log
search.controller.cost.log.open=true
#rateLimit config
search.persional.rateLimit.brand.productList=200:2
search.persional.rateLimit.brand.aggregations=100:2
... ... @@ -94,7 +96,6 @@ search.persional.rateLimit.zq.aggregations=100:2
search.persional.rateLimit.group_brands=100:2
search.persional.rateLimit.group_shops=100:2
search.persional.rateLimit.search=100:2
search.persional.rateLimit.productindex.productList=100:2
search.persional.rateLimit.productindex.productListWithPhrase=100:2
... ...