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


Java AggregationBuilders.sum方法代码示例

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


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

示例1: exitAggregate_mapping

import org.elasticsearch.search.aggregations.AggregationBuilders; //导入方法依赖的package包/类
@Override
public void exitAggregate_mapping(EQLParser.Aggregate_mappingContext ctx) {
    // TODO I don't need AggMapping
    AggMapping am = new AggMapping(ctx.ID().getText(), (FunCall)getValue(ctx.funcall()));
    ValuesSourceMetricsAggregationBuilder b;
    switch(am.getFc().getFunName()) {
        case AVG:
            b = AggregationBuilders.avg(am.getId()); break;
        case MAX:
            b = AggregationBuilders.max(am.getId()); break;
        case MIN:
            b = AggregationBuilders.min(am.getId()); break;
        case SUM:
            b = AggregationBuilders.sum(am.getId()); break;
        default:
            throw new RuntimeException("Invalid function");
    }
    b.field(am.getFc().getField());
    setValue(ctx, b);
}
 
开发者ID:metadave,项目名称:eql,代码行数:21,代码来源:EQLWalker.java

示例2: makeFieldAgg

import org.elasticsearch.search.aggregations.AggregationBuilders; //导入方法依赖的package包/类
/**
 * Create aggregation according to the SQL function.
 *
 * @param field  SQL function
 * @param parent parentAggregation
 * @return AggregationBuilder represents the SQL function
 * @throws SqlParseException in case of unrecognized function
 */
public AggregationBuilder makeFieldAgg(MethodField field, AggregationBuilder parent) throws SqlParseException {
    groupMap.put(field.getAlias(), new KVValue("FIELD", parent));
    ValuesSourceAggregationBuilder builder;
    field.setAlias(fixAlias(field.getAlias()));
    switch (field.getName().toUpperCase()) {
        case "SUM":
            builder = AggregationBuilders.sum(field.getAlias());
            return addFieldToAgg(field, builder);
        case "MAX":
            builder = AggregationBuilders.max(field.getAlias());
            return addFieldToAgg(field, builder);
        case "MIN":
            builder = AggregationBuilders.min(field.getAlias());
            return addFieldToAgg(field, builder);
        case "AVG":
            builder = AggregationBuilders.avg(field.getAlias());
            return addFieldToAgg(field, builder);
        case "STATS":
            builder = AggregationBuilders.stats(field.getAlias());
            return addFieldToAgg(field, builder);
        case "EXTENDED_STATS":
            builder = AggregationBuilders.extendedStats(field.getAlias());
            return addFieldToAgg(field, builder);
        case "PERCENTILES":
            builder = AggregationBuilders.percentiles(field.getAlias());
            addSpecificPercentiles((PercentilesAggregationBuilder) builder, field.getParams());
            return addFieldToAgg(field, builder);
        case "TOPHITS":
            return makeTopHitsAgg(field);
        case "SCRIPTED_METRIC":
            return scriptedMetric(field);
        case "COUNT":
            groupMap.put(field.getAlias(), new KVValue("COUNT", parent));
            return makeCountAgg(field);
        default:
            throw new SqlParseException("the agg function not to define !");
    }
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:47,代码来源:AggMaker.java

示例3: makeFieldAgg

import org.elasticsearch.search.aggregations.AggregationBuilders; //导入方法依赖的package包/类
/**
 * Create aggregation according to the SQL function.
 *
 * @param field  SQL function
 * @param parent parentAggregation
 * @return AggregationBuilder represents the SQL function
 * @throws SqlParseException in case of unrecognized function
 */
public AggregationBuilder makeFieldAgg(MethodField field, AggregationBuilder parent) throws SqlParseException {
    groupMap.put(field.getAlias(), new KVValue("FIELD", parent));
    ValuesSourceAggregationBuilder builder;
    field.setAlias(fixAlias(field.getAlias()));
    switch (field.getName().toUpperCase()) {
        case "SUM":
            builder = AggregationBuilders.sum(field.getAlias());
            return addFieldToAgg(field, builder);
        case "MAX":
            builder = AggregationBuilders.max(field.getAlias());
            return addFieldToAgg(field, builder);
        case "MIN":
            builder = AggregationBuilders.min(field.getAlias());
            return addFieldToAgg(field, builder);
        case "AVG":
            builder = AggregationBuilders.avg(field.getAlias());
            return addFieldToAgg(field, builder);
        case "STATS":
            builder = AggregationBuilders.stats(field.getAlias());
            return addFieldToAgg(field, builder);
        case "EXTENDED_STATS":
            builder = AggregationBuilders.extendedStats(field.getAlias());
            return addFieldToAgg(field, builder);
        case "PERCENTILES":
            builder = AggregationBuilders.percentiles(field.getAlias());
            addSpecificPercentiles((PercentilesAggregationBuilder) builder, field.getParams());
            return addFieldToAgg(field, builder);
        case "TOPHITS":
            return makeTopHitsAgg(field);
        case "SCRIPTED_METRIC":
            return scriptedMetric(field);
        case "COUNT":
            groupMap.put(field.getAlias(), new KVValue("COUNT", parent));
            return addFieldToAgg(field, makeCountAgg(field));
        default:
            throw new SqlParseException("the agg function not to define !");
    }
}
 
开发者ID:NLPchina,项目名称:elasticsearch-sql,代码行数:47,代码来源:AggMaker.java

示例4: makeFieldAgg

import org.elasticsearch.search.aggregations.AggregationBuilders; //导入方法依赖的package包/类
/**
 * Create aggregation according to the SQL function.
 * @param field SQL function
 * @param parent parentAggregation
 * @return AggregationBuilder represents the SQL function
 * @throws SqlParseException in case of unrecognized function
 */
public AbstractAggregationBuilder makeFieldAgg(MethodField field, AbstractAggregationBuilder parent) throws SqlParseException {
	groupMap.put(field.getAlias(), new KVValue("FIELD", parent));
       ValuesSourceMetricsAggregationBuilder builder;
       field.setAlias(fixAlias(field.getAlias()));
	switch (field.getName().toUpperCase()) {
	case "SUM":
		builder = AggregationBuilders.sum(field.getAlias());
           addFieldOrScriptToAggregation(field, builder);
           return builder;
	case "MAX":
		builder = AggregationBuilders.max(field.getAlias());
           addFieldOrScriptToAggregation(field, builder);
           return builder;
	case "MIN":
		builder =  AggregationBuilders.min(field.getAlias());
           addFieldOrScriptToAggregation(field, builder);
           return builder;
	case "AVG":
		builder =  AggregationBuilders.avg(field.getAlias());
           addFieldOrScriptToAggregation(field, builder);
           return builder;
	case "STATS":
		builder =  AggregationBuilders.stats(field.getAlias());
           addFieldOrScriptToAggregation(field, builder);
           return builder;
       case "EXTENDED_STATS":
           builder =  AggregationBuilders.extendedStats(field.getAlias());
           addFieldOrScriptToAggregation(field, builder);
           return builder;
       case "PERCENTILES":
           builder = AggregationBuilders.percentiles(field.getAlias());
           addFieldOrScriptToAggregation(field, builder);
           return builder;
	case "TOPHITS":
		return makeTopHitsAgg(field);
       case "SCRIPTED_METRIC":
           return scriptedMetric(field);
	case "COUNT":
		groupMap.put(field.getAlias(), new KVValue("COUNT", parent));
		return makeCountAgg(field);
	default:
		throw new SqlParseException("the agg function not to define !");
	}
}
 
开发者ID:selvakumarEsra,项目名称:es4sql,代码行数:52,代码来源:AggMaker.java


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