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 {
public static final String PARAM_SEARCH_NOT_BRAND_ID = "not_brandId";
public static final String PARAM_SEARCH_NOT_SHOP_ID = "not_shopId";
public static final String PARAM_SEARCH_NOT_PROMOTION = "not_promotion";
public static final String PARAM_SEARCH_NOT_MAXSORT_ID = "not_maxSortId";
// 活动模板相关过滤条件
public static final String PARAM_SEARCH_ACT_TEMP = "act_temp"; // 模板id
... ...
... ... @@ -239,6 +239,9 @@ public class SearchQueryHelper {
this.addMustNotIntTermsQuery(boolFilter,paramMap,filterParamName,SearchRequestParams.PARAM_SEARCH_NOT_SHOP_ID,ProductIndexEsField.shopId);
// 优惠价类型
addMustNotIntTermsQuery(boolFilter, paramMap, filterParamName, SearchRequestParams.PARAM_SEARCH_COUPONLIMITTYPES,ProductIndexEsField.couponLimitTypes);
//品类id
this.addMustNotIntTermsQuery(boolFilter,paramMap,filterParamName,SearchRequestParams.PARAM_SEARCH_NOT_MAXSORT_ID,ProductIndexEsField.maxSortId);
// //////////////////////////////////////////只支持单个String参数///////////////////////////////////////////////////////////
// 是否特价
... ...
package com.yoho.search.service.scene.pages;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yoho.search.base.utils.SearchPageIdDefine;
import com.yoho.search.common.SearchRequestParams;
import com.yoho.search.common.utils.SearchApiResultUtils;
import com.yoho.search.models.SearchApiResult;
import com.yoho.search.common.SearchRequestParams;
import com.yoho.search.service.helper.SearchCommonHelper;
import com.yoho.search.service.helper.SearchKeyWordHelper;
import com.yoho.search.service.scene.pages.entrance.ProductListSwitchService;
... ... @@ -16,6 +17,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Iterator;
import java.util.Map;
@Service
... ... @@ -46,6 +48,7 @@ public class MiniappFuzzyPageSceneService extends AbstractPageSceneService {
super.addDefaultParamsToParamMap(paramMap);
super.filterNotNormalToMap(paramMap);
paramMap.put(SearchRequestParams.PARAM_SEARCH_NEED_SUGGESTION, "Y");// 返回建议词
paramMap.put(SearchRequestParams.PARAM_SEARCH_NOT_MAXSORT_ID, "1186");
paramMap.remove(SearchRequestParams.PARAM_SEARCH_ISADVANCE);// 放开普通预售
}
... ... @@ -69,19 +72,49 @@ public class MiniappFuzzyPageSceneService extends AbstractPageSceneService {
// 4、加入建议词
fuzzySceneService.addSuggestion(productListResult, paramMap);
// 5、模糊搜索页记录关键字对应的查询结果
// 5、去除成人用品关键字
this.removeBlackKeyword(productListResult);
// 6、模糊搜索页记录关键字对应的查询结果
String queryWord = paramMap.get("query");
if (!StringUtils.isBlank(queryWord) && !searchCommonHelper.isQuerySknOrSku(queryWord)) {
long total = ((JSONObject) productListResult.getData()).getLongValue("total");
searchKeyWordService.recordKeyWordByResultCount(queryWord, total);
}
//6、返回结果
// 7、返回结果
return productListResult;
} catch (Exception e) {
return SearchApiResultUtils.errorSearchApiResult(logger, paramMap, e);
}
}
private void removeBlackKeyword(SearchApiResult productListResult) {
try {
JSONObject result = (JSONObject) productListResult.getData();
if (result == null) {
return;
}
JSONObject suggestion = result.getJSONObject("suggestion");
if (suggestion == null) {
return;
}
JSONArray termsSuggestion = suggestion.getJSONArray("terms_suggestion");
if (termsSuggestion == null || termsSuggestion.isEmpty()) {
return;
}
Iterator<Object> iterator = termsSuggestion.iterator();
while (iterator.hasNext()) {
String keyWord = iterator.next().toString();
if (keyWord.contains("成人")) {
iterator.remove();
}
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
@Override
public SearchApiResult aggregations(Map<String, String> paramMap) {
try {
... ... @@ -93,7 +126,7 @@ public class MiniappFuzzyPageSceneService extends AbstractPageSceneService {
this.addParamsToParamMap(paramMap);
// 2、返回聚合结果
SearchApiResult result = pageSelectionsService.aggregations(paramMap);
if(result!=null){
if (result != null) {
scenePageSelectionsBrandsService.getRecommendBrands(paramMap, result);
}
return result;
... ...