...
|
...
|
@@ -45,6 +45,7 @@ import com.yoho.search.service.service.base.ShopsIndexBaseService; |
|
|
import com.yoho.search.service.service.helper.SearchCommonHelper;
|
|
|
import com.yoho.search.service.service.helper.SearchServiceHelper;
|
|
|
import com.yoho.search.service.servicenew.IShopListService;
|
|
|
import com.yoho.search.service.utils.SearchKeyWordUtils;
|
|
|
import com.yoho.search.service.utils.SearchRequestParams;
|
|
|
import com.yoho.search.service.vo.SearchApiResult;
|
|
|
import com.yoho.search.service.vo.SearchSort;
|
...
|
...
|
@@ -67,37 +68,17 @@ public class ShopListServiceImpl implements IShopListService { |
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(ShopsServiceImpl.class);
|
|
|
|
|
|
private String getLegalKeyWord(Map<String, String> paramMap) {
|
|
|
String keyword = paramMap.get(SearchRequestParams.PARAM_SEARCH_SHOPS_KEYWORD);
|
|
|
if (StringUtils.isBlank(keyword)) {
|
|
|
return null;
|
|
|
}
|
|
|
if (keyword.contains("%")) {
|
|
|
keyword.replace("%", "percent");// 特殊处理
|
|
|
}
|
|
|
// 编码转换
|
|
|
String is_encode = paramMap.get("is_encode");
|
|
|
if (StringUtils.isNotBlank(is_encode) && is_encode.equals("1")) {
|
|
|
try {
|
|
|
keyword = URLDecoder.decode(keyword, "UTF-8");
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
logger.warn(e.getMessage(), e);
|
|
|
}
|
|
|
}
|
|
|
return keyword;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public SearchApiResult searchShopList(Map<String, String> paramMap) {
|
|
|
logger.info("[func=searchShops][param={}][begin={}]", paramMap.toString(), System.currentTimeMillis());
|
|
|
// 1、获取搜索店铺的关键词
|
|
|
String keyword = this.getLegalKeyWord(paramMap);
|
|
|
String keyword = SearchKeyWordUtils.getParamKeyword(paramMap);
|
|
|
if (StringUtils.isBlank(keyword)) {
|
|
|
return new SearchApiResult().setCode(400).setMessage("请传keyword");
|
|
|
}
|
|
|
SearchParam searchParam = new SearchParam();
|
|
|
searchParam.setSize(0);
|
|
|
|
|
|
|
|
|
// 2、构建query
|
|
|
MultiMatchQueryBuilder queryBuilder = QueryBuilders.multiMatchQuery(keyword);
|
|
|
queryBuilder.operator(MatchQueryBuilder.Operator.OR);
|
...
|
...
|
|