Showing
3 changed files
with
25 additions
and
41 deletions
@@ -27,6 +27,29 @@ public class SceneRecommendBrandsService { | @@ -27,6 +27,29 @@ public class SceneRecommendBrandsService { | ||
27 | @Autowired | 27 | @Autowired |
28 | private UserPersionalFactorComponent userPersionalFactorComponent; | 28 | private UserPersionalFactorComponent userPersionalFactorComponent; |
29 | 29 | ||
30 | + public void getRecommendBrands(Map<String, String> paramMap, SearchApiResult result) { | ||
31 | + getRecommendBrands(paramMap, result, null); | ||
32 | + } | ||
33 | + | ||
34 | + public void getRecommendBrands(Map<String, String> paramMap, SearchApiResult result, BoolQueryBuilder extFilter) { | ||
35 | + if (result != null && result.getData() != null) { | ||
36 | + JSONObject data = (JSONObject) result.getData(); | ||
37 | + JSONObject commonFilters = data.getJSONObject("filter"); | ||
38 | + if (commonFilters != null) { | ||
39 | + getRecommendBrandsNew(commonFilters, paramMap); | ||
40 | + } | ||
41 | + } | ||
42 | + } | ||
43 | + | ||
44 | + private void getRecommendBrandsNew(JSONObject commonFilters, Map<String, String> paramMap) { | ||
45 | + JSONArray recommendBrands = new JSONArray(); | ||
46 | + JSONArray brandList = commonFilters.getJSONArray("brand"); | ||
47 | + if (!CollectionUtils.isEmpty(brandList)) { | ||
48 | + recommendBrands = getRecommendBrands(paramMap, brandList); | ||
49 | + } | ||
50 | + commonFilters.put("recommendBrand", recommendBrands); | ||
51 | + } | ||
52 | + | ||
30 | private JSONArray getRecommendBrands(Map<String, String> paramMap, JSONArray brandList) { | 53 | private JSONArray getRecommendBrands(Map<String, String> paramMap, JSONArray brandList) { |
31 | List<JSONObject> brandListTemp = JSON.parseObject(brandList.toJSONString(), new TypeReference<List<JSONObject>>() { | 54 | List<JSONObject> brandListTemp = JSON.parseObject(brandList.toJSONString(), new TypeReference<List<JSONObject>>() { |
32 | }); | 55 | }); |
@@ -68,26 +91,4 @@ public class SceneRecommendBrandsService { | @@ -68,26 +91,4 @@ public class SceneRecommendBrandsService { | ||
68 | return recBrands; | 91 | return recBrands; |
69 | } | 92 | } |
70 | 93 | ||
71 | - public void getRecommendBrands(Map<String, String> paramMap, SearchApiResult result) { | ||
72 | - getRecommendBrands(paramMap, result, null); | ||
73 | - } | ||
74 | - | ||
75 | - public void getRecommendBrands(Map<String, String> paramMap, SearchApiResult result, BoolQueryBuilder extFilter) { | ||
76 | - if (result != null && result.getData() != null) { | ||
77 | - JSONObject data = (JSONObject) result.getData(); | ||
78 | - JSONObject commonFilters = data.getJSONObject("filter"); | ||
79 | - if (commonFilters != null) { | ||
80 | - getRecommendBrandsNew(commonFilters, paramMap); | ||
81 | - } | ||
82 | - } | ||
83 | - } | ||
84 | - | ||
85 | - private void getRecommendBrandsNew(JSONObject commonFilters, Map<String, String> paramMap) { | ||
86 | - JSONArray recommendBrands = new JSONArray(); | ||
87 | - JSONArray brandList = commonFilters.getJSONArray("brand"); | ||
88 | - if (!CollectionUtils.isEmpty(brandList)) { | ||
89 | - recommendBrands = getRecommendBrands(paramMap, brandList); | ||
90 | - } | ||
91 | - commonFilters.put("recommendBrand", recommendBrands); | ||
92 | - } | ||
93 | } | 94 | } |
@@ -16,14 +16,6 @@ public interface IAggRecommendService { | @@ -16,14 +16,6 @@ public interface IAggRecommendService { | ||
16 | */ | 16 | */ |
17 | SearchApiResult aggRecommendBrand(Map<String, String> paramMap); | 17 | SearchApiResult aggRecommendBrand(Map<String, String> paramMap); |
18 | 18 | ||
19 | - /** | ||
20 | - * 获取品牌的聚合结果[使用本地缓存] | ||
21 | - * | ||
22 | - * @param paramMap | ||
23 | - * @return | ||
24 | - */ | ||
25 | - SearchApiResult aggRecommendBrand(Map<String, String> paramMap, BoolQueryBuilder mustFilter); | ||
26 | - | ||
27 | 19 | ||
28 | /** | 20 | /** |
29 | * 获取店铺的聚合结果[使用本地缓存] | 21 | * 获取店铺的聚合结果[使用本地缓存] |
@@ -54,20 +54,11 @@ public class AggRecommendServiceImpl extends AbstractCacheAbleService implements | @@ -54,20 +54,11 @@ public class AggRecommendServiceImpl extends AbstractCacheAbleService implements | ||
54 | public SearchApiResult aggRecommendBrand(Map<String, String> paramMap) { | 54 | public SearchApiResult aggRecommendBrand(Map<String, String> paramMap) { |
55 | try { | 55 | try { |
56 | logger.info("[func=aggRecommendBrand][param={}][begin={}]", paramMap.toString(), System.currentTimeMillis()); | 56 | logger.info("[func=aggRecommendBrand][param={}][begin={}]", paramMap.toString(), System.currentTimeMillis()); |
57 | - return this.aggRecommendBrand(paramMap, null); | ||
58 | - } catch (Exception e) { | ||
59 | - return SearchApiResultUtils.errorSearchApiResult("aggRecommendBrand", paramMap, e); | ||
60 | - } | ||
61 | - } | ||
62 | - | ||
63 | - @Override | ||
64 | - public SearchApiResult aggRecommendBrand(Map<String, String> paramMap, BoolQueryBuilder mustFilter) { | ||
65 | - try { | ||
66 | // 0、开关支持是否关闭个性化 | 57 | // 0、开关支持是否关闭个性化 |
67 | if (!searchDynamicConfigService.isRecommendPersionalOpen()) { | 58 | if (!searchDynamicConfigService.isRecommendPersionalOpen()) { |
68 | paramMap.remove("uid"); | 59 | paramMap.remove("uid"); |
69 | } | 60 | } |
70 | - | 61 | + |
71 | // 1、获取核心参数 | 62 | // 1、获取核心参数 |
72 | boolean needPreAggregation = true; | 63 | boolean needPreAggregation = true; |
73 | String aggWithParamBrand = paramMap.get(SearchRequestParams.PARAM_SEARCH_AGG_WITH_PARAM_BRAND); | 64 | String aggWithParamBrand = paramMap.get(SearchRequestParams.PARAM_SEARCH_AGG_WITH_PARAM_BRAND); |
@@ -77,7 +68,7 @@ public class AggRecommendServiceImpl extends AbstractCacheAbleService implements | @@ -77,7 +68,7 @@ public class AggRecommendServiceImpl extends AbstractCacheAbleService implements | ||
77 | int recommendBrandCount = Integer.parseInt(paramMap.getOrDefault(SearchRequestParams.PARAM_SEARCH_VIEWNUM, "8")); | 68 | int recommendBrandCount = Integer.parseInt(paramMap.getOrDefault(SearchRequestParams.PARAM_SEARCH_VIEWNUM, "8")); |
78 | 69 | ||
79 | // 2、构建带queryBuilder和filter的SearchParam | 70 | // 2、构建带queryBuilder和filter的SearchParam |
80 | - SearchParam searchParam = searchParamHelper.buildSearchParam(paramMap, true, mustFilter, needPreAggregation ? "brand" : null); | 71 | + SearchParam searchParam = searchParamHelper.buildSearchParam(paramMap, true, null, needPreAggregation ? "brand" : null); |
81 | 72 | ||
82 | // 3、构造聚合 | 73 | // 3、构造聚合 |
83 | IAggregation recommendBrandAgg = aggregationFactoryService.getRecommendBrandAggregation(paramMap, recommendBrandCount); | 74 | IAggregation recommendBrandAgg = aggregationFactoryService.getRecommendBrandAggregation(paramMap, recommendBrandCount); |
-
Please register or login to post a comment