Authored by hugufei

Merge branch 'master' into gray0904

# Conflicts:
#	service/src/main/java/com/yoho/search/service/scene/pages/MiniappFuzzyPageSceneService.java
@@ -93,6 +93,7 @@ public class SearchRequestParams { @@ -93,6 +93,7 @@ public class SearchRequestParams {
93 public static final String PARAM_SEARCH_NOT_BRAND_ID = "not_brandId"; 93 public static final String PARAM_SEARCH_NOT_BRAND_ID = "not_brandId";
94 public static final String PARAM_SEARCH_NOT_SHOP_ID = "not_shopId"; 94 public static final String PARAM_SEARCH_NOT_SHOP_ID = "not_shopId";
95 public static final String PARAM_SEARCH_NOT_PROMOTION = "not_promotion"; 95 public static final String PARAM_SEARCH_NOT_PROMOTION = "not_promotion";
  96 + public static final String PARAM_SEARCH_NOT_MAXSORT_ID = "not_maxSortId";
96 97
97 // 活动模板相关过滤条件 98 // 活动模板相关过滤条件
98 public static final String PARAM_SEARCH_ACT_TEMP = "act_temp"; // 模板id 99 public static final String PARAM_SEARCH_ACT_TEMP = "act_temp"; // 模板id
@@ -239,6 +239,9 @@ public class SearchQueryHelper { @@ -239,6 +239,9 @@ public class SearchQueryHelper {
239 this.addMustNotIntTermsQuery(boolFilter,paramMap,filterParamName,SearchRequestParams.PARAM_SEARCH_NOT_SHOP_ID,ProductIndexEsField.shopId); 239 this.addMustNotIntTermsQuery(boolFilter,paramMap,filterParamName,SearchRequestParams.PARAM_SEARCH_NOT_SHOP_ID,ProductIndexEsField.shopId);
240 // 优惠价类型 240 // 优惠价类型
241 addMustNotIntTermsQuery(boolFilter, paramMap, filterParamName, SearchRequestParams.PARAM_SEARCH_COUPONLIMITTYPES,ProductIndexEsField.couponLimitTypes); 241 addMustNotIntTermsQuery(boolFilter, paramMap, filterParamName, SearchRequestParams.PARAM_SEARCH_COUPONLIMITTYPES,ProductIndexEsField.couponLimitTypes);
  242 + //品类id
  243 + this.addMustNotIntTermsQuery(boolFilter,paramMap,filterParamName,SearchRequestParams.PARAM_SEARCH_NOT_MAXSORT_ID,ProductIndexEsField.maxSortId);
  244 +
242 245
243 // //////////////////////////////////////////只支持单个String参数/////////////////////////////////////////////////////////// 246 // //////////////////////////////////////////只支持单个String参数///////////////////////////////////////////////////////////
244 // 是否特价 247 // 是否特价
1 package com.yoho.search.service.scene.pages; 1 package com.yoho.search.service.scene.pages;
2 2
  3 +import com.alibaba.fastjson.JSONArray;
3 import com.alibaba.fastjson.JSONObject; 4 import com.alibaba.fastjson.JSONObject;
4 import com.yoho.search.base.utils.SearchPageIdDefine; 5 import com.yoho.search.base.utils.SearchPageIdDefine;
  6 +import com.yoho.search.common.SearchRequestParams;
5 import com.yoho.search.common.utils.SearchApiResultUtils; 7 import com.yoho.search.common.utils.SearchApiResultUtils;
6 import com.yoho.search.models.SearchApiResult; 8 import com.yoho.search.models.SearchApiResult;
7 -import com.yoho.search.common.SearchRequestParams;  
8 import com.yoho.search.service.helper.SearchCommonHelper; 9 import com.yoho.search.service.helper.SearchCommonHelper;
9 import com.yoho.search.service.helper.SearchKeyWordHelper; 10 import com.yoho.search.service.helper.SearchKeyWordHelper;
10 import com.yoho.search.service.scene.pages.entrance.ProductListSwitchService; 11 import com.yoho.search.service.scene.pages.entrance.ProductListSwitchService;
@@ -16,6 +17,7 @@ import org.slf4j.LoggerFactory; @@ -16,6 +17,7 @@ import org.slf4j.LoggerFactory;
16 import org.springframework.beans.factory.annotation.Autowired; 17 import org.springframework.beans.factory.annotation.Autowired;
17 import org.springframework.stereotype.Service; 18 import org.springframework.stereotype.Service;
18 19
  20 +import java.util.Iterator;
19 import java.util.Map; 21 import java.util.Map;
20 22
21 @Service 23 @Service
@@ -46,6 +48,7 @@ public class MiniappFuzzyPageSceneService extends AbstractPageSceneService { @@ -46,6 +48,7 @@ public class MiniappFuzzyPageSceneService extends AbstractPageSceneService {
46 super.addDefaultParamsToParamMap(paramMap); 48 super.addDefaultParamsToParamMap(paramMap);
47 super.filterNotNormalToMap(paramMap); 49 super.filterNotNormalToMap(paramMap);
48 paramMap.put(SearchRequestParams.PARAM_SEARCH_NEED_SUGGESTION, "Y");// 返回建议词 50 paramMap.put(SearchRequestParams.PARAM_SEARCH_NEED_SUGGESTION, "Y");// 返回建议词
  51 + paramMap.put(SearchRequestParams.PARAM_SEARCH_NOT_MAXSORT_ID, "1186");
49 paramMap.remove(SearchRequestParams.PARAM_SEARCH_ISADVANCE);// 放开普通预售 52 paramMap.remove(SearchRequestParams.PARAM_SEARCH_ISADVANCE);// 放开普通预售
50 } 53 }
51 54
@@ -69,19 +72,49 @@ public class MiniappFuzzyPageSceneService extends AbstractPageSceneService { @@ -69,19 +72,49 @@ public class MiniappFuzzyPageSceneService extends AbstractPageSceneService {
69 // 4、加入建议词 72 // 4、加入建议词
70 fuzzySceneService.addSuggestion(productListResult, paramMap); 73 fuzzySceneService.addSuggestion(productListResult, paramMap);
71 74
72 - // 5、模糊搜索页记录关键字对应的查询结果 75 + // 5、去除成人用品关键字
  76 + this.removeBlackKeyword(productListResult);
  77 +
  78 + // 6、模糊搜索页记录关键字对应的查询结果
73 String queryWord = paramMap.get("query"); 79 String queryWord = paramMap.get("query");
74 if (!StringUtils.isBlank(queryWord) && !searchCommonHelper.isQuerySknOrSku(queryWord)) { 80 if (!StringUtils.isBlank(queryWord) && !searchCommonHelper.isQuerySknOrSku(queryWord)) {
75 long total = ((JSONObject) productListResult.getData()).getLongValue("total"); 81 long total = ((JSONObject) productListResult.getData()).getLongValue("total");
76 searchKeyWordService.recordKeyWordByResultCount(queryWord, total); 82 searchKeyWordService.recordKeyWordByResultCount(queryWord, total);
77 } 83 }
78 - //6、返回结果 84 + // 7、返回结果
79 return productListResult; 85 return productListResult;
80 } catch (Exception e) { 86 } catch (Exception e) {
81 return SearchApiResultUtils.errorSearchApiResult(logger, paramMap, e); 87 return SearchApiResultUtils.errorSearchApiResult(logger, paramMap, e);
82 } 88 }
83 } 89 }
84 90
  91 + private void removeBlackKeyword(SearchApiResult productListResult) {
  92 + try {
  93 + JSONObject result = (JSONObject) productListResult.getData();
  94 + if (result == null) {
  95 + return;
  96 + }
  97 + JSONObject suggestion = result.getJSONObject("suggestion");
  98 + if (suggestion == null) {
  99 + return;
  100 + }
  101 + JSONArray termsSuggestion = suggestion.getJSONArray("terms_suggestion");
  102 + if (termsSuggestion == null || termsSuggestion.isEmpty()) {
  103 + return;
  104 + }
  105 + Iterator<Object> iterator = termsSuggestion.iterator();
  106 + while (iterator.hasNext()) {
  107 + String keyWord = iterator.next().toString();
  108 + if (keyWord.contains("成人")) {
  109 + iterator.remove();
  110 + }
  111 + }
  112 + } catch (Exception e) {
  113 + logger.error(e.getMessage(), e);
  114 + }
  115 + }
  116 +
  117 +
85 @Override 118 @Override
86 public SearchApiResult aggregations(Map<String, String> paramMap) { 119 public SearchApiResult aggregations(Map<String, String> paramMap) {
87 try { 120 try {
@@ -93,7 +126,7 @@ public class MiniappFuzzyPageSceneService extends AbstractPageSceneService { @@ -93,7 +126,7 @@ public class MiniappFuzzyPageSceneService extends AbstractPageSceneService {
93 this.addParamsToParamMap(paramMap); 126 this.addParamsToParamMap(paramMap);
94 // 2、返回聚合结果 127 // 2、返回聚合结果
95 SearchApiResult result = pageSelectionsService.aggregations(paramMap); 128 SearchApiResult result = pageSelectionsService.aggregations(paramMap);
96 - if(result!=null){ 129 + if (result != null) {
97 scenePageSelectionsBrandsService.getRecommendBrands(paramMap, result); 130 scenePageSelectionsBrandsService.getRecommendBrands(paramMap, result);
98 } 131 }
99 return result; 132 return result;