Authored by unknown

添加场景化的默认参数以及模糊搜索的定制参数

... ... @@ -48,6 +48,13 @@ public class FuzzySceneService extends AbstractSceneService {
return SearchPageIdDefine.PAGE_ID_SEARCH;
}
@Override
public void addParamsToParamMap(Map<String, String> paramMap) {
super.addDefaultParamsToParamMap(paramMap);
paramMap.put(SearchRequestParams.PARAM_SEARCH_NEED_SUGGESTION, "Y");// 返回建议词
paramMap.put(SearchRequestParams.PARAM_SEARCH_CONTAIN_SECKILL, "Y");// 包含秒杀商品
}
/**
* @1、返回商品列表
* @2、数量太多则返回建议词
... ... @@ -90,24 +97,28 @@ public class FuzzySceneService extends AbstractSceneService {
if (StringUtils.isEmpty(queryWord) || (queryWord.length() > 30 && !searchCommonHelper.isQuerySkn(queryWord))) {
return;
}
// 1.2 请求制定需要返回term推荐
// 1.2不是第一页直接不返回
int page = this.getPage(paramMap);
if (page != 1) {
return;
}
// 1.3请求制定需要返回term推荐
if (!"Y".equalsIgnoreCase(paramMap.get(SearchRequestParams.PARAM_SEARCH_NEED_SUGGESTION))) {
return;
}
// 1.3 打开智能推荐全局开关
// 1.4打开智能推荐全局开关
if (!searchDynamicConfigService.isSearchSuggestionTipsOpen()) {
return;
}
// 1.4 搜索的数量小于20条
// 1.5 搜索的数量小于20条
JSONObject dataMap = ((JSONObject) searchResult.getData());
if (dataMap.getIntValue("total") >= SMART_SUGGESTION_PRODUCT_LIMIT) {
return;
}
// 1.5加入推荐词
// 1.6加入推荐词
dataMap.put("suggestion", searchRecommendService.recommend(searchResult, paramMap));
}
... ...
... ... @@ -4,6 +4,8 @@ import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.apache.commons.lang.StringUtils;
import com.yoho.search.service.utils.SearchRequestParams;
import com.yoho.search.service.vo.SearchApiResult;
... ... @@ -11,12 +13,30 @@ public abstract class AbstractSceneService {
protected static ExecutorService executorService = Executors.newFixedThreadPool(500);
protected void addParamsToParamMap(Map<String, String> paramMap) {
/**
* 场景化的默认参数
*
* @param paramMap
*/
protected void addDefaultParamsToParamMap(Map<String, String> paramMap) {
paramMap.put(SearchRequestParams.PARAM_SEARCH_PAGEID, this.pageId());
paramMap.put(SearchRequestParams.PARAM_SEARCH_GLOBAL_FILTER_BRAND, "Y");// 屏蔽参数
paramMap.put("aggWithParamBrand", "Y");// 聚合品牌只取参数中的brand聚合
paramMap.put(SearchRequestParams.PARAM_SEARCH_GLOBAL_FILTER_BRAND, "Y");// 页面屏蔽
paramMap.put(SearchRequestParams.PARAM_SEARCH_STATUS, "1");// 上架
paramMap.put(SearchRequestParams.PARAM_SEARCH_STOCKNUM, "1");// 有库存
paramMap.put(SearchRequestParams.PARAM_SEARCH_SHOWSOLDOUT, "1");// 显示售罄商品
paramMap.put(SearchRequestParams.PARAM_SEARCH_CONTAIN_GLOBAL, "Y");// 包含全球购
paramMap.put(SearchRequestParams.PARAM_SEARCH_ISOUTLETS, "2");// 非奥莱
paramMap.put("attribute_not", "2");// 非赠品
// paramMap.put("sale", "Y");// 没用的参数
}
protected int getPage(Map<String, String> paramMap) {
int page = StringUtils.isBlank(paramMap.get("page")) ? 1 : Integer.parseInt(paramMap.get("page"));
return page;
}
public abstract void addParamsToParamMap(Map<String, String> paramMap);
public abstract String pageId();
public abstract SearchApiResult productList(Map<String, String> paramMap);
... ...