|
@ -131,7 +131,6 @@ public class ViewService extends BaseJpaService<View, ViewDao> {
|
|
|
* @param sortJsonStr 排序JSON字符串,如:'{"cubeCode":"xxx","field":"event_date","sort":"asc"}',cubeCode 为多维数据集编码。
|
|
|
* @param drillJsonStr 钻取维度JSON字符串,如:'{"cubeCode":"xxx","field":"event_date","replaced":{"cubeCode":"xxx","field":"event_date"}}',
|
|
|
* "cubeCode 为多维数据集编码,replaced 为被替换的行维度。
|
|
|
* @return
|
|
|
*/
|
|
|
public void adjustViewRule(View viewRule, String sortJsonStr, String drillJsonStr) throws Exception {
|
|
|
List<ViewDimension> topDimensionList = viewRule.getGroupTopRowDimensionList();
|
|
@ -395,6 +394,7 @@ public class ViewService extends BaseJpaService<View, ViewDao> {
|
|
|
|
|
|
String fieldType = cubeService.findDimensionDataType(viewDimension.getCubeCode(), dimensionCode);
|
|
|
if (!"date".equals(fieldType)) {
|
|
|
// 非日期维度字段聚合场合
|
|
|
String aggName = dimensionCode + "-terms";
|
|
|
dimensionAgg = AggregationBuilders.terms(aggName).field(dimensionCode);
|
|
|
|
|
@ -418,15 +418,17 @@ public class ViewService extends BaseJpaService<View, ViewDao> {
|
|
|
if (memberCount != null && memberCount > 0) {
|
|
|
((TermsBuilder) dimensionAgg).size(memberCount);
|
|
|
} else {
|
|
|
// TODO 需动态获取全部的分组个数进行设置
|
|
|
((TermsBuilder) dimensionAgg).size(1000);
|
|
|
// TODO 需动态获取维度的全部分组项个数进行设置
|
|
|
((TermsBuilder) dimensionAgg).size(500);
|
|
|
}
|
|
|
} else {
|
|
|
// 日期维度字段聚合场合
|
|
|
String aggName = dimensionCode + "-date_histogram";
|
|
|
dimensionAgg = AggregationBuilders.dateHistogram(aggName).field(dimensionCode);
|
|
|
((DateHistogramBuilder) dimensionAgg).minDocCount(0);
|
|
|
((DateHistogramBuilder) dimensionAgg).format(viewDimension.getMemberDateFormat());
|
|
|
((DateHistogramBuilder) dimensionAgg).interval(new DateHistogramInterval(viewDimension.getMemberDateInterval()));
|
|
|
|
|
|
// 设置排序
|
|
|
Histogram.Order order = isAsc ? Histogram.Order.KEY_ASC : Histogram.Order.KEY_DESC;
|
|
|
if (StringUtils.isEmpty(orderType) || "name".equals(orderType)) {
|