...
|
...
|
@@ -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
|
...
|
...
|
|