...
|
...
|
@@ -148,7 +148,8 @@ public class SearchWithLocalCacheServiceImpl implements ISearchWithLocalCacheSer |
|
|
public SearchApiResult productList(Map<String, String> paramMap) {
|
|
|
try {
|
|
|
logger.info("[func=productList][param={}][begin={}]", paramMap, System.currentTimeMillis());
|
|
|
|
|
|
|
|
|
//1)构造搜索参数
|
|
|
SearchParam searchParam = buildProductListSearchParam(paramMap);
|
|
|
|
|
|
// 5)从缓存中获取数据
|
...
|
...
|
@@ -167,29 +168,17 @@ public class SearchWithLocalCacheServiceImpl implements ISearchWithLocalCacheSer |
|
|
}
|
|
|
// 7)记录关键字对应的查询结果
|
|
|
String queryWord = paramMap.get("query");
|
|
|
|
|
|
//编码转换
|
|
|
String is_encode = paramMap.get("is_encode");
|
|
|
if(StringUtils.isNotBlank(is_encode)&&is_encode.equals("1")){
|
|
|
try {
|
|
|
queryWord = URLDecoder.decode(queryWord, "UTF-8");
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
logger.warn(e.getMessage(),e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (!StringUtils.isBlank(queryWord) && !searchServiceHelper.isQuerySkn(queryWord)) {
|
|
|
searchKeyWordService.recordKeyWordByResultCount(queryWord, searchResult.getTotal());
|
|
|
}
|
|
|
// 8)当返回结果为空时,先记录请求参数,然后修改operator为or并重新搜索,minimum修改为50%
|
|
|
if (StringUtils.isNotBlank("queryWord") && 0 == searchResult.getTotal()) {
|
|
|
if (StringUtils.isNotBlank(queryWord) && 0 == searchResult.getTotal()) {
|
|
|
searchKeyWordService.handleEmptyRecords(paramMap);
|
|
|
logger.info("search result is empty by operator of AND, will use operator of OR to reenforce search result");
|
|
|
searchParam.setQuery(searchServiceHelper.constructOrQueryBuilder(paramMap));
|
|
|
searchResult = searchCommonService.doSearch(indexName, searchParam);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 9)构造返回结果
|
|
|
JSONObject dataMap = new JSONObject();
|
|
|
dataMap.put("total", searchResult.getTotal());
|
...
|
...
|
|