...
|
...
|
@@ -400,13 +400,14 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl |
|
|
// 8) 构建结果加入缓存 将拼写纠错的词放在第一个
|
|
|
suggestResult = new JSONObject();
|
|
|
List<String> resultTerms = searchResult.getResultList().stream().map(map -> (String) map.get("keyword")).collect(Collectors.toList());
|
|
|
logger.info("[func=suggestTipsBySuggestIndex][resultTerms={}][correntSpellingSuggestResultTerms={}]", resultTerms, correntSpellingSuggestResultTerms);
|
|
|
if (CollectionUtils.isNotEmpty(correntSpellingSuggestResultTerms)) {
|
|
|
if (CollectionUtils.isEmpty(resultTerms)) {
|
|
|
// 8.1) 如果拼写检查返回的结果不为空而原先的结果为空 则使用拼写检查的
|
|
|
resultTerms = correntSpellingSuggestResultTerms;
|
|
|
} else if (correntSpellingSuggestResultTerms.contains(correnctSpellingKeyword)) {
|
|
|
// 8.2) 如果拼写检查返回的结果不为空而原先的结果也不为空 则将拼写纠错词放在第一位 这里用contains是确保纠错词的count不会小于20个商品
|
|
|
resultTerms = addCorrectSpellingKeywordToFirst(queryWord, correnctSpellingKeyword, resultTerms);
|
|
|
} else if (correntSpellingSuggestResultTerms.get(0).equalsIgnoreCase(correnctSpellingKeyword)) {
|
|
|
// 8.2) 如果拼写检查返回的结果不为空而原先的结果也不为空 则将拼写纠错词放在第一位 这里进行equals判断是确保纠错词的count不会小于20个商品
|
|
|
resultTerms = addCorrectSpellingKeywordToFirst(queryWord, correntSpellingSuggestResultTerms.get(0), resultTerms);
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -494,14 +495,14 @@ public class SuggestServiceImpl implements ISuggestService, ApplicationEventPubl |
|
|
return null;
|
|
|
}
|
|
|
|
|
|
// 优先返回品类
|
|
|
// 优先返回品类 要求名称的长度要大于1
|
|
|
List<String> resultTerms = new ArrayList<>();
|
|
|
List<String> smallSortList = (List<String>) smallSortNameAgg.getAggregationResponseMap(productIndexSearchResult.getAggMaps());
|
|
|
List<String> brandNameList = (List<String>) brandNameAgg.getAggregationResponseMap(productIndexSearchResult.getAggMaps());
|
|
|
List<String> styleNameList = (List<String>) styleNameAgg.getAggregationResponseMap(productIndexSearchResult.getAggMaps());
|
|
|
resultTerms.addAll(smallSortList);
|
|
|
resultTerms.addAll(brandNameList);
|
|
|
resultTerms.addAll(styleNameList);
|
|
|
resultTerms.addAll(smallSortList.stream().filter(name -> name != null && name.length() > 1).collect(Collectors.toSet()));
|
|
|
resultTerms.addAll(brandNameList.stream().filter(name -> name != null && name.length() > 1).collect(Collectors.toSet()));
|
|
|
resultTerms.addAll(styleNameList.stream().filter(name -> name != null && name.length() > 1).collect(Collectors.toSet()));
|
|
|
|
|
|
// 移除queryWord 避免重复
|
|
|
String standardQueryWord = CharUtils.standardized(queryWord);
|
...
|
...
|
|