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