|
@@ -45,6 +45,7 @@ import com.yoho.search.service.service.base.ShopsIndexBaseService; |
|
@@ -45,6 +45,7 @@ import com.yoho.search.service.service.base.ShopsIndexBaseService; |
45
|
import com.yoho.search.service.service.helper.SearchCommonHelper;
|
45
|
import com.yoho.search.service.service.helper.SearchCommonHelper;
|
46
|
import com.yoho.search.service.service.helper.SearchServiceHelper;
|
46
|
import com.yoho.search.service.service.helper.SearchServiceHelper;
|
47
|
import com.yoho.search.service.servicenew.IShopListService;
|
47
|
import com.yoho.search.service.servicenew.IShopListService;
|
|
|
48
|
+import com.yoho.search.service.utils.SearchKeyWordUtils;
|
48
|
import com.yoho.search.service.utils.SearchRequestParams;
|
49
|
import com.yoho.search.service.utils.SearchRequestParams;
|
49
|
import com.yoho.search.service.vo.SearchApiResult;
|
50
|
import com.yoho.search.service.vo.SearchApiResult;
|
50
|
import com.yoho.search.service.vo.SearchSort;
|
51
|
import com.yoho.search.service.vo.SearchSort;
|
|
@@ -67,37 +68,17 @@ public class ShopListServiceImpl implements IShopListService { |
|
@@ -67,37 +68,17 @@ public class ShopListServiceImpl implements IShopListService { |
67
|
|
68
|
|
68
|
private static final Logger logger = LoggerFactory.getLogger(ShopsServiceImpl.class);
|
69
|
private static final Logger logger = LoggerFactory.getLogger(ShopsServiceImpl.class);
|
69
|
|
70
|
|
70
|
- private String getLegalKeyWord(Map<String, String> paramMap) {
|
|
|
71
|
- String keyword = paramMap.get(SearchRequestParams.PARAM_SEARCH_SHOPS_KEYWORD);
|
|
|
72
|
- if (StringUtils.isBlank(keyword)) {
|
|
|
73
|
- return null;
|
|
|
74
|
- }
|
|
|
75
|
- if (keyword.contains("%")) {
|
|
|
76
|
- keyword.replace("%", "percent");// 特殊处理
|
|
|
77
|
- }
|
|
|
78
|
- // 编码转换
|
|
|
79
|
- String is_encode = paramMap.get("is_encode");
|
|
|
80
|
- if (StringUtils.isNotBlank(is_encode) && is_encode.equals("1")) {
|
|
|
81
|
- try {
|
|
|
82
|
- keyword = URLDecoder.decode(keyword, "UTF-8");
|
|
|
83
|
- } catch (UnsupportedEncodingException e) {
|
|
|
84
|
- logger.warn(e.getMessage(), e);
|
|
|
85
|
- }
|
|
|
86
|
- }
|
|
|
87
|
- return keyword;
|
|
|
88
|
- }
|
|
|
89
|
-
|
|
|
90
|
@Override
|
71
|
@Override
|
91
|
public SearchApiResult searchShopList(Map<String, String> paramMap) {
|
72
|
public SearchApiResult searchShopList(Map<String, String> paramMap) {
|
92
|
logger.info("[func=searchShops][param={}][begin={}]", paramMap.toString(), System.currentTimeMillis());
|
73
|
logger.info("[func=searchShops][param={}][begin={}]", paramMap.toString(), System.currentTimeMillis());
|
93
|
// 1、获取搜索店铺的关键词
|
74
|
// 1、获取搜索店铺的关键词
|
94
|
- String keyword = this.getLegalKeyWord(paramMap);
|
75
|
+ String keyword = SearchKeyWordUtils.getParamKeyword(paramMap);
|
95
|
if (StringUtils.isBlank(keyword)) {
|
76
|
if (StringUtils.isBlank(keyword)) {
|
96
|
return new SearchApiResult().setCode(400).setMessage("请传keyword");
|
77
|
return new SearchApiResult().setCode(400).setMessage("请传keyword");
|
97
|
}
|
78
|
}
|
98
|
SearchParam searchParam = new SearchParam();
|
79
|
SearchParam searchParam = new SearchParam();
|
99
|
searchParam.setSize(0);
|
80
|
searchParam.setSize(0);
|
100
|
-
|
81
|
+
|
101
|
// 2、构建query
|
82
|
// 2、构建query
|
102
|
MultiMatchQueryBuilder queryBuilder = QueryBuilders.multiMatchQuery(keyword);
|
83
|
MultiMatchQueryBuilder queryBuilder = QueryBuilders.multiMatchQuery(keyword);
|
103
|
queryBuilder.operator(MatchQueryBuilder.Operator.OR);
|
84
|
queryBuilder.operator(MatchQueryBuilder.Operator.OR);
|