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