Prechádzať zdrojové kódy

es数据解析 解析

jkzlzhoujie 6 rokov pred
rodič
commit
ad0d335335

+ 20 - 16
src/main/java/com/yihu/quota/util/AggregationBuildHandler.java

@ -335,7 +335,8 @@ public class AggregationBuildHandler {
        List<String> cloumnList = new ArrayList<>();
        List<ViewDimension> colDimensionList = viewDimensionDao.getColDimensionList(viewId);
        for (ViewDimension colViewDimension : colDimensionList) {
            cloumnList.add(colViewDimension.getDimensionCode());
            String aggCode = getDimensionAggCode(colViewDimension.getCubeCode(), colViewDimension.getDimensionCode());
            cloumnList.add(aggCode);
        }
        return cloumnList;
    }
@ -350,29 +351,32 @@ public class AggregationBuildHandler {
        // 视图各组组内顶层行维度(升序)
        List<ViewDimension> groupTopRowDimensionList = viewDimensionDao.getGroupTopRowDimensionList(viewId);
        for (ViewDimension viewDimension : groupTopRowDimensionList) {
            String aggType = "-terms";
            String dataType = cubeService.findDimensionDataType("cubeCode:1", viewDimension.getDimensionCode());
            if(!StringUtils.isEmpty(dataType)){
                if(dataType.equals("date")){
                    aggType = "-date_histogram";
                }
            }
            rowList.add(viewDimension.getDimensionCode() + aggType);
            String aggCode = getDimensionAggCode(viewDimension.getCubeCode(), viewDimension.getDimensionCode());
            rowList.add(aggCode);
            List<ViewDimension> otherRowDimensionList = viewDimensionDao.getGroupOtherRowDimensionList(viewId, viewDimension.getGroupRow());
            for (ViewDimension otherViewDimension : otherRowDimensionList) {
                rowList.add(otherViewDimension.getDimensionCode() + aggType);;
                String otherAggCode = getDimensionAggCode(otherViewDimension.getCubeCode(), viewDimension.getDimensionCode());
                rowList.add(otherAggCode);
            }
        }
        return rowList;
    }
    private List<Aggregation> getAggregationList(Iterator<Terms.Bucket> gradeBucket){
        List<Aggregation> aggregationList = new ArrayList<>();
        while (gradeBucket.hasNext()) {
            Terms.Bucket b = gradeBucket.next();
            aggregationList = b.getAggregations().asList();
    /**
     * 查询数据集中维度的数据类型
     * @param cubeCode
     * @param dimensionCode
     * @return
     */
    public String getDimensionAggCode(String cubeCode,String dimensionCode){
        String aggType = "-terms";
        String dataType = cubeService.findDimensionDataType(cubeCode, dimensionCode);
        if(!StringUtils.isEmpty(dataType)){
            if(dataType.equals("date")){
                aggType = "-date_histogram";
            }
        }
        return  aggregationList;
        return  dimensionCode + aggType;
    }
    /**