|
@@ -9,7 +9,6 @@ import java.util.Iterator; |
|
@@ -9,7 +9,6 @@ import java.util.Iterator; |
9
|
import java.util.LinkedHashMap;
|
9
|
import java.util.LinkedHashMap;
|
10
|
import java.util.List;
|
10
|
import java.util.List;
|
11
|
import java.util.Map;
|
11
|
import java.util.Map;
|
12
|
-import java.util.Map.Entry;
|
|
|
13
|
|
12
|
|
14
|
import com.yoho.search.base.utils.ConvertUtils;
|
13
|
import com.yoho.search.base.utils.ConvertUtils;
|
15
|
import com.yoho.search.common.cache.aop.SearchCacheAble;
|
14
|
import com.yoho.search.common.cache.aop.SearchCacheAble;
|
|
@@ -57,7 +56,6 @@ import com.yoho.search.service.aggregations.impls.AggregationFactoryService; |
|
@@ -57,7 +56,6 @@ import com.yoho.search.service.aggregations.impls.AggregationFactoryService; |
57
|
import com.yoho.search.service.base.SearchCommonService;
|
56
|
import com.yoho.search.service.base.SearchCommonService;
|
58
|
import com.yoho.search.service.base.SearchRequestParams;
|
57
|
import com.yoho.search.service.base.SearchRequestParams;
|
59
|
import com.yoho.search.service.base.index.BrandIndexBaseService;
|
58
|
import com.yoho.search.service.base.index.BrandIndexBaseService;
|
60
|
-import com.yoho.search.service.base.index.ProductIndexBaseService;
|
|
|
61
|
import com.yoho.search.service.helper.SearchCommonHelper;
|
59
|
import com.yoho.search.service.helper.SearchCommonHelper;
|
62
|
import com.yoho.search.service.helper.SearchParamHelper;
|
60
|
import com.yoho.search.service.helper.SearchParamHelper;
|
63
|
import com.yoho.search.service.helper.SearchSortHelper;
|
61
|
import com.yoho.search.service.helper.SearchSortHelper;
|
|
@@ -380,6 +378,31 @@ public class BrandServiceImpl extends AbstractCacheAbleService implements IBrand |
|
@@ -380,6 +378,31 @@ public class BrandServiceImpl extends AbstractCacheAbleService implements IBrand |
380
|
}
|
378
|
}
|
381
|
}
|
379
|
}
|
382
|
|
380
|
|
|
|
381
|
+
|
|
|
382
|
+ @Override
|
|
|
383
|
+ public SearchApiResult searchBrand(Map<String, String> paramMap) {
|
|
|
384
|
+ // 1、参数校验
|
|
|
385
|
+ if (StringUtils.isBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_QUERY))) {
|
|
|
386
|
+ return new SearchApiResult().setCode(400).setMessage("请传query参数");
|
|
|
387
|
+ }
|
|
|
388
|
+ // 1)构建参数
|
|
|
389
|
+ SearchParam searchParam = new SearchParam();
|
|
|
390
|
+ searchParam.setSize(10);
|
|
|
391
|
+ searchParam.setQuery(QueryBuilders.matchQuery("brandName", paramMap.get(SearchRequestParams.PARAM_SEARCH_QUERY)));
|
|
|
392
|
+
|
|
|
393
|
+ // 2、brand数据量比较大,走本地缓存。guavacache缓存中获取result,没有到es中获取
|
|
|
394
|
+ final String brandIndexName = ISearchConstants.INDEX_NAME_BRAND;
|
|
|
395
|
+ // 3、执行搜索
|
|
|
396
|
+ SearchResult searchResult = searchCommonService.doSearch(brandIndexName, searchParam);
|
|
|
397
|
+ if (searchResult == null || searchResult.getResultList().isEmpty()) {
|
|
|
398
|
+ return new SearchApiResult().setCode(400).setMessage("empty result");
|
|
|
399
|
+ }
|
|
|
400
|
+ Map<String, List> data = new HashMap<>();
|
|
|
401
|
+ data.put("brands", searchResult.getResultList());
|
|
|
402
|
+ return new SearchApiResult().setCode(200).setData(data);
|
|
|
403
|
+ }
|
|
|
404
|
+
|
|
|
405
|
+
|
383
|
private JSONArray getNewBrandResponseMap(MultiBucketsAggregation aggregation, int size, List<Integer> brandIds, final String realSortField, final SortOrder realSortOrder) {
|
406
|
private JSONArray getNewBrandResponseMap(MultiBucketsAggregation aggregation, int size, List<Integer> brandIds, final String realSortField, final SortOrder realSortOrder) {
|
384
|
// 1、首先获取全部品牌的商品列表
|
407
|
// 1、首先获取全部品牌的商品列表
|
385
|
Iterator<? extends Bucket> itAgg = aggregation.getBuckets().iterator();
|
408
|
Iterator<? extends Bucket> itAgg = aggregation.getBuckets().iterator();
|