...
|
...
|
@@ -446,16 +446,17 @@ public class SearchService { |
|
|
searchParam.setQuery(searchServiceHelper.constructQueryBuilder(paramMap));
|
|
|
searchParam.setFiter(searchServiceHelper.constructFilterBuilder(paramMap, null));
|
|
|
}
|
|
|
|
|
|
|
|
|
// 构造聚合条件(如果需要小分类,则加上小分类的聚合)
|
|
|
List<AbstractAggregationBuilder> aggregationBuilders = new ArrayList<AbstractAggregationBuilder>();
|
|
|
TermsBuilder builder = AggregationBuilders.terms("maxAgg").field("maxSortName").size(50)
|
|
|
.subAggregation(AggregationBuilders.terms("middleAgg").field("middleSortName").size(100));
|
|
|
TermsBuilder maxAggBuilder = AggregationBuilders.terms("maxAgg").field("maxSortName").size(50);
|
|
|
TermsBuilder middleAggBuilder = AggregationBuilders.terms("middleAgg").field("middleSortName").size(50);
|
|
|
TermsBuilder smallAggBuilder = AggregationBuilders.terms("smallAgg").field("smallSortName").size(50);
|
|
|
if (paramMap.containsKey("needSmallSort") && "1".equals(paramMap.get("needSmallSort"))) {
|
|
|
builder.subAggregation(AggregationBuilders.terms("smallAgg").field("smallSortName").size(100));
|
|
|
maxAggBuilder.subAggregation(middleAggBuilder.subAggregation(smallAggBuilder));
|
|
|
} else {
|
|
|
maxAggBuilder.subAggregation(middleAggBuilder);
|
|
|
}
|
|
|
aggregationBuilders.add(builder);
|
|
|
searchParam.setAggregationBuilders(aggregationBuilders);
|
|
|
searchParam.setAggregationBuilders(Arrays.asList(maxAggBuilder));
|
|
|
|
|
|
// 设置查询结果返回字段
|
|
|
List<String> resultFields = new ArrayList<String>();
|
...
|
...
|
|