Authored by hugufei

BUG

@@ -376,20 +376,15 @@ public class SearchService { @@ -376,20 +376,15 @@ public class SearchService {
376 searchParam.setQuery(searchServiceHelper.constructQueryBuilder(paramMap)); 376 searchParam.setQuery(searchServiceHelper.constructQueryBuilder(paramMap));
377 377
378 // 取每个品牌需要hit到的viewNum个产品数量 378 // 取每个品牌需要hit到的viewNum个产品数量
379 - List<AbstractAggregationBuilder> aggregationBuilders = new ArrayList<AbstractAggregationBuilder>();  
380 TermsBuilder aggregationBuilder = AggregationBuilders.terms("brandAgg").field("brandId").size(100); 379 TermsBuilder aggregationBuilder = AggregationBuilders.terms("brandAgg").field("brandId").size(100);
381 int size = StringUtils.isBlank(paramMap.get("viewNum")) ? 10 : Integer.parseInt(paramMap.get("viewNum")); 380 int size = StringUtils.isBlank(paramMap.get("viewNum")) ? 10 : Integer.parseInt(paramMap.get("viewNum"));
382 if (size > 0) { 381 if (size > 0) {
383 aggregationBuilder.subAggregation(AggregationBuilders.topHits("product").setSize(size)); 382 aggregationBuilder.subAggregation(AggregationBuilders.topHits("product").setSize(size));
384 } 383 }
385 - // if (size == 0) {  
386 - // aggregationBuilders.add(AggregationBuilders.terms("brandAgg").field("brandId").size(100));  
387 - // } else {  
388 - // aggregationBuilders.add(AggregationBuilders.terms("brandAgg").field("brandId").size(100).subAggregation();  
389 - // }  
390 -  
391 - searchParam.setAggregationBuilders(aggregationBuilders); 384 + searchParam.setAggregationBuilders(Arrays.asList(aggregationBuilder));
392 searchParam.setSearchType(SearchType.COUNT); 385 searchParam.setSearchType(SearchType.COUNT);
  386 +
  387 + //查询
393 final String indexName = ISearchConstans.INDEX_NAME_PRODUCT_INDEX; 388 final String indexName = ISearchConstans.INDEX_NAME_PRODUCT_INDEX;
394 SearchResult searchResult = searchCommonService.doSearch(indexName, searchParam); 389 SearchResult searchResult = searchCommonService.doSearch(indexName, searchParam);
395 Map<String, Object> jsonMap = new HashMap<String, Object>(); 390 Map<String, Object> jsonMap = new HashMap<String, Object>();