Authored by wangnan9279

去掉没有用的ufo suggest接口

... ... @@ -56,13 +56,6 @@ public class UfoController {
return ufoProductListService.recommendList(paramMap);
}
@RequestMapping(method = RequestMethod.GET, value = "/ufo/suggestList")
@ResponseBody
public SearchApiResult suggestList(HttpServletRequest request) {
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
return ufoProductListService.suggestList(paramMap);
}
@RequestMapping(method = RequestMethod.GET, value = "/ufo/productListForPlatform")
@ResponseBody
public SearchApiResult productListForPlatform(HttpServletRequest request) {
... ...
... ... @@ -139,17 +139,6 @@ public class UfoSearchQueryHelper extends BaseService {
return queryBuilder;
}
public QueryBuilder constructSuggestQueryBuilder(Map<String, String> paramMap) {
// 0、处理查询关键字
String query = SearchKeyWordUtils.getUfoParamKeyword(paramMap, SearchRequestParams.UFOPRODUCTINDEX_SEARCH_QUERY);
if (StringUtils.isBlank(query)) {
return QueryBuilders.matchAllQuery();
}
WildcardQueryBuilder wildcardQueryBuilder = QueryBuilders.wildcardQuery(UfoProductIndexEsField.productName_ik, "*" + query + "*");
return wildcardQueryBuilder;
}
/**
* 构造排序方式
*/
... ...
... ... @@ -86,18 +86,5 @@ public class UfoProductIndexBaseService {
return productMap;
}
public List<Map<String, Object>> buildSuggestReturnInfoList(List<Map<String, Object>> productEsSourceList) {
List<Map<String, Object>> results = new ArrayList<Map<String, Object>>();
for (Map<String, Object> productEsSource : productEsSourceList) {
results.add(this.getSuggestFromEsSource(productEsSource));
}
return results;
}
public Map<String, Object> getSuggestFromEsSource(Map<String, Object> map) {
Map<String, Object> productMap = new HashMap<String, Object>();
productMap.put("product_name", MapUtils.getString(map, UfoProductIndexEsField.productName, ""));
return productMap;
}
}
... ...
... ... @@ -166,44 +166,6 @@ public class UfoProductListService {
}
}
public SearchApiResult suggestList(Map<String, String> paramMap) {
try {
// 1、参数校验
int pageSize = StringUtils.isBlank(paramMap.get("viewNum")) ? 10 : Integer.parseInt(paramMap.get("viewNum"));
if (pageSize < 0) {
return new SearchApiResult().setCode(400).setMessage("viewNum参数不合法");
}
if (pageSize > 100) {
paramMap.put("viewNum", "100");
}
// 2. 构建SearchParam
SearchParam searchParam = new SearchParam();
BoolQueryBuilder boolFilter = ufoSearchQueryHelper.constructFilterBuilder(paramMap, null);
searchParam.setFiter(boolFilter);
QueryBuilder queryBuilder = ufoSearchQueryHelper.constructSuggestQueryBuilder(paramMap);
searchParam.setQuery(queryBuilder);
searchParam.setAggregationBuilders(null);
searchParam.setSize(pageSize);
searchParam.setOffset(0);
// 设置返回的结果
List<String> includeFields = ufoProductIndexBaseService.getUfoProductIndexIncludeFields();
searchParam.setIncludeFields(includeFields);
// 执行搜索
SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_UFO_PRODUCT_INDEX, searchParam);
// 构造返回结果
List<Map<String, Object>> returnInfoList = ufoProductIndexBaseService.buildSuggestReturnInfoList(searchResult.getResultList());
JSONObject dataMap = new JSONObject();
dataMap.put("size", pageSize);
dataMap.put("total", searchResult.getTotalPage());
dataMap.put("suggest_list", returnInfoList);
return new SearchApiResult().setData(dataMap);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new SearchApiResult().setData(null).setCode(500);
}
}
public SearchApiResult productListForPlatform(Map<String, String> paramMap) {
try {
// 2. 构建SearchParam
... ...