当前位置: 首页>>代码示例>>Java>>正文


Java AggregationBuilders.nested方法代码示例

本文整理汇总了Java中org.elasticsearch.search.aggregations.AggregationBuilders.nested方法的典型用法代码示例。如果您正苦于以下问题:Java AggregationBuilders.nested方法的具体用法?Java AggregationBuilders.nested怎么用?Java AggregationBuilders.nested使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.search.aggregations.AggregationBuilders的用法示例。


在下文中一共展示了AggregationBuilders.nested方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createNestedAggregation

import org.elasticsearch.search.aggregations.AggregationBuilders; //导入方法依赖的package包/类
private AggregationBuilder createNestedAggregation(Field field) {
    AggregationBuilder nestedBuilder;

    String nestedPath = field.getNestedPath();

    if (field.isReverseNested()) {
        if (nestedPath == null || !nestedPath.startsWith("~")) {
            ReverseNestedAggregationBuilder reverseNestedAggregationBuilder = AggregationBuilders.reverseNested(getNestedAggName(field));
            if(nestedPath!=null){
                reverseNestedAggregationBuilder.path(nestedPath);
            }
            return reverseNestedAggregationBuilder;
        }
        nestedPath = nestedPath.substring(1);
    }

    nestedBuilder = AggregationBuilders.nested(getNestedAggName(field),nestedPath);

    return nestedBuilder;
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:21,代码来源:AggregationQueryAction.java

示例2: addFieldToAgg

import org.elasticsearch.search.aggregations.AggregationBuilders; //导入方法依赖的package包/类
private AggregationBuilder addFieldToAgg(MethodField field, ValuesSourceAggregationBuilder builder) {
    KVValue kvValue = field.getParams().get(0);
    if (kvValue.key != null && kvValue.key.equals("script")) {
        if (kvValue.value instanceof MethodField) {
            return builder.script(new Script(((MethodField) kvValue.value).getParams().get(1).toString()));
        } else {
            return builder.script(new Script(kvValue.value.toString()));
        }

    } else if (kvValue.key != null && kvValue.value.toString().trim().startsWith("def")) {
        return builder.script(new Script(kvValue.value.toString()));
    } else if (kvValue.key != null && (kvValue.key.equals("nested") || kvValue.key.equals("reverse_nested"))) {
        NestedType nestedType = (NestedType) kvValue.value;

        builder.field(nestedType.field);

        AggregationBuilder nestedBuilder;

        String nestedAggName = nestedType.field + "@NESTED";

        if (nestedType.isReverse()) {
            if (nestedType.path != null && nestedType.path.startsWith("~")) {
                String realPath = nestedType.path.substring(1);
                nestedBuilder = AggregationBuilders.nested(nestedAggName,realPath);
                nestedBuilder = nestedBuilder.subAggregation(builder);
                return AggregationBuilders.reverseNested(nestedAggName + "_REVERSED").subAggregation(nestedBuilder);
            } else {
                ReverseNestedAggregationBuilder reverseNestedAggregationBuilder = AggregationBuilders.reverseNested(nestedAggName);
                if (nestedType.path!=null){
                    reverseNestedAggregationBuilder.path(nestedType.path);
                }
                nestedBuilder = reverseNestedAggregationBuilder;
            }
        } else {
            nestedBuilder = AggregationBuilders.nested(nestedAggName,nestedType.path);
        }

        return nestedBuilder.subAggregation(builder);
    } else if (kvValue.key != null && (kvValue.key.equals("children"))) {
        ChildrenType childrenType = (ChildrenType) kvValue.value;

        builder.field(childrenType.field);

        AggregationBuilder childrenBuilder;

        String childrenAggName = childrenType.field + "@CHILDREN";

        childrenBuilder = JoinAggregationBuilders.children(childrenAggName,childrenType.childType);

        return childrenBuilder;
    }

    return builder.field(kvValue.toString());
}
 
开发者ID:NLPchina,项目名称:elasticsearch-sql,代码行数:55,代码来源:AggMaker.java

示例3: addFieldToAgg

import org.elasticsearch.search.aggregations.AggregationBuilders; //导入方法依赖的package包/类
private AggregationBuilder addFieldToAgg(MethodField field, ValuesSourceAggregationBuilder builder) {
    KVValue kvValue = field.getParams().get(0);
    if (kvValue.key != null && kvValue.key.equals("script")) {
        if (kvValue.value instanceof MethodField) {
            return builder.script(new Script(((MethodField) kvValue.value).getParams().get(1).toString()));
        } else {
            return builder.script(new Script(kvValue.value.toString()));
        }

    } else if (kvValue.key != null && kvValue.value.toString().trim().startsWith("def")) {
        return builder.script(new Script(kvValue.value.toString()));
    } else if (kvValue.key != null && (kvValue.key.equals("nested") || kvValue.key.equals("reverse_nested"))) {
        NestedType nestedType = (NestedType) kvValue.value;

        builder.field(nestedType.field);

        AggregationBuilder nestedBuilder;

        String nestedAggName = nestedType.field + "@NESTED";

        if (nestedType.isReverse()) {
            if (nestedType.path != null && nestedType.path.startsWith("~")) {
                String realPath = nestedType.path.substring(1);
                nestedBuilder = AggregationBuilders.nested(nestedAggName,realPath);
                nestedBuilder = nestedBuilder.subAggregation(builder);
                return AggregationBuilders.reverseNested(nestedAggName + "_REVERSED").subAggregation(nestedBuilder);
            } else {
                ReverseNestedAggregationBuilder reverseNestedAggregationBuilder = AggregationBuilders.reverseNested(nestedAggName);
                if (nestedType.path!=null){
                    reverseNestedAggregationBuilder.path(nestedType.path);
                }
                nestedBuilder = reverseNestedAggregationBuilder;
            }
        } else {
            nestedBuilder = AggregationBuilders.nested(nestedAggName,nestedType.path);
        }

        return nestedBuilder.subAggregation(builder);
    } else if (kvValue.key != null && (kvValue.key.equals("children"))) {
        ChildrenType childrenType = (ChildrenType) kvValue.value;

        builder.field(childrenType.field);

        AggregationBuilder childrenBuilder;

        String childrenAggName = childrenType.field + "@CHILDREN";

        childrenBuilder = AggregationBuilders.children(childrenAggName,childrenType.childType);

        return childrenBuilder;
    }

    return builder.field(kvValue.toString());
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:55,代码来源:AggMaker.java


注:本文中的org.elasticsearch.search.aggregations.AggregationBuilders.nested方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。