Authored by unknown

推荐品牌的BUG

1 package com.yoho.search.service.scene.common; 1 package com.yoho.search.service.scene.common;
2 2
3 import java.util.ArrayList; 3 import java.util.ArrayList;
  4 +import java.util.HashMap;
4 import java.util.List; 5 import java.util.List;
5 import java.util.Map; 6 import java.util.Map;
6 import java.util.concurrent.CompletableFuture; 7 import java.util.concurrent.CompletableFuture;
@@ -225,19 +226,21 @@ public class SceneSelectionsService extends BaseService { @@ -225,19 +226,21 @@ public class SceneSelectionsService extends BaseService {
225 226
226 private JSONObject getFiltersResult(Map<String, String> paramMap, List<IAggregation> aggregations, BoolQueryBuilder mustFilter) { 227 private JSONObject getFiltersResult(Map<String, String> paramMap, List<IAggregation> aggregations, BoolQueryBuilder mustFilter) {
227 try { 228 try {
228 - SearchParam searchParam = searchParamHelper.buildWithMustFilter(paramMap, mustFilter); 229 + Map<String, String> newParamMap = new HashMap<String, String>(paramMap);
  230 + SearchParam searchParam = searchParamHelper.buildWithMustFilter(newParamMap, mustFilter);
229 return this.getFiltersResults(paramMap, searchParam, aggregations); 231 return this.getFiltersResults(paramMap, searchParam, aggregations);
230 } catch (Exception e) { 232 } catch (Exception e) {
231 - logger.error("[func=fuzzyAggregations][params=" + paramMap + "]", e); 233 + logger.error("[func=SceneSelectionsService][params=" + paramMap + "]", e);
232 return new JSONObject(); 234 return new JSONObject();
233 } 235 }
234 } 236 }
235 - 237 +
236 private JSONArray getRecommendBrands(Map<String, String> paramMap, BoolQueryBuilder mustFilter) { 238 private JSONArray getRecommendBrands(Map<String, String> paramMap, BoolQueryBuilder mustFilter) {
237 - SearchApiResult searchApiResult = aggRecommendService.aggRecommendBrand(paramMap, mustFilter); 239 + Map<String, String> newParamMap = new HashMap<String, String>(paramMap);
  240 + SearchApiResult searchApiResult = aggRecommendService.aggRecommendBrand(newParamMap, mustFilter);
238 return (JSONArray) searchApiResult.getData(); 241 return (JSONArray) searchApiResult.getData();
239 } 242 }
240 - 243 +
241 public SearchApiResult aggregations(Map<String, String> paramMap) throws Exception { 244 public SearchApiResult aggregations(Map<String, String> paramMap) throws Exception {
242 List<IAggregation> commonAggregations = this.getCommonAggregations(paramMap); 245 List<IAggregation> commonAggregations = this.getCommonAggregations(paramMap);
243 return this.aggregations(paramMap, commonAggregations, null); 246 return this.aggregations(paramMap, commonAggregations, null);
@@ -75,11 +75,12 @@ public class AggRecommendServiceImpl implements IAggRecommendService { @@ -75,11 +75,12 @@ public class AggRecommendServiceImpl implements IAggRecommendService {
75 needPreAggregation = false; 75 needPreAggregation = false;
76 } 76 }
77 int recommendBrandCount = Integer.parseInt(paramMap.getOrDefault(SearchRequestParams.PARAM_SEARCH_VIEWNUM, "8")); 77 int recommendBrandCount = Integer.parseInt(paramMap.getOrDefault(SearchRequestParams.PARAM_SEARCH_VIEWNUM, "8"));
78 - paramMap.remove(SearchRequestParams.PARAM_SEARCH_ORDER);// 此接口 78 + // paramMap.remove(SearchRequestParams.PARAM_SEARCH_ORDER);//
  79 + // 此接口不支持ORDER参数【只会按人气或者个性化打分排序】
79 80
80 // 2、构建带queryBuilder和filter的SearchParam 81 // 2、构建带queryBuilder和filter的SearchParam
81 SearchParam searchParam = searchParamHelper.buildSearchParam(paramMap, true, mustFilter, needPreAggregation ? "brand" : null); 82 SearchParam searchParam = searchParamHelper.buildSearchParam(paramMap, true, mustFilter, needPreAggregation ? "brand" : null);
82 - 83 +
83 // 3、构造聚合 84 // 3、构造聚合
84 IAggregation recommendBrandAgg = aggregationFactoryService.getRecommendBrandAggregation(paramMap, recommendBrandCount); 85 IAggregation recommendBrandAgg = aggregationFactoryService.getRecommendBrandAggregation(paramMap, recommendBrandCount);
85 searchParam.setAggregationBuilders(Arrays.asList(recommendBrandAgg.getBuilder())); 86 searchParam.setAggregationBuilders(Arrays.asList(recommendBrandAgg.getBuilder()));