org.elasticsearch.search.aggregations.metrics.stats.extended.InternalExtendedStats Java Examples

The following examples show how to use org.elasticsearch.search.aggregations.metrics.stats.extended.InternalExtendedStats. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Utils.java    From foxtrot with Apache License 2.0 6 votes vote down vote up
public static Map<String, Number> toStats(Aggregation statAggregation) {
    if (statAggregation instanceof InternalExtendedStats) {
        return Utils.createStatsResponse((InternalExtendedStats) statAggregation);
    }
    else if (statAggregation instanceof InternalStats) {
        return Utils.createStatsResponse((InternalStats) statAggregation);
    }
    else if (statAggregation instanceof InternalMax) {
        return Utils.createStatResponse((InternalMax) statAggregation);
    }
    else if (statAggregation instanceof InternalMin) {
        return Utils.createStatResponse((InternalMin) statAggregation);
    }
    else if (statAggregation instanceof InternalAvg) {
        return Utils.createStatResponse((InternalAvg) statAggregation);
    }
    else if (statAggregation instanceof InternalSum) {
        return Utils.createStatResponse((InternalSum) statAggregation);
    }
    else if (statAggregation instanceof InternalValueCount) {
        return Utils.createStatResponse((InternalValueCount) statAggregation);
    }
    return new HashMap<>();
}
 
Example #2
Source File: Utils.java    From foxtrot with Apache License 2.0 5 votes vote down vote up
public static Map<String, Number> createStatsResponse(InternalExtendedStats extendedStats) {
    Map<String, Number> stats = Maps.newHashMap();
    stats.put(AVG, extendedStats.getAvg());
    stats.put(SUM, extendedStats.getSum());
    stats.put(COUNT, extendedStats.getCount());
    stats.put(MIN, extendedStats.getMin());
    stats.put(MAX, extendedStats.getMax());
    stats.put(SUM_OF_SQUARES, extendedStats.getSumOfSquares());
    stats.put(VARIANCE, extendedStats.getVariance());
    stats.put(STD_DEVIATION, extendedStats.getStdDeviation());
    return stats;
}
 
Example #3
Source File: ElasticsearchGraphQueryIterable.java    From vertexium with Apache License 2.0 4 votes vote down vote up
private static AggregationResult reduceAggregationResults(ElasticsearchSearchQueryBase query, org.vertexium.query.Aggregation queryAgg, List<Aggregation> resultAggs) {
    if (resultAggs.size() == 0) {
        throw new VertexiumException("Cannot reduce zero sized aggregation list");
    }

    Object aggType = queryAgg;
    if (queryAgg == null) {
        Aggregation first = resultAggs.get(0);
        if (first.getName().endsWith(AGGREGATION_HAS_NOT_SUFFIX)) {
            if (resultAggs.size() > 1) {
                first = resultAggs.get(1);
            } else {
                throw new VertexiumException("Unhandled aggregation. Found HasNot filter with no associated aggregations and no query aggregation.");
            }
        }
        aggType = first;
    }

    if (aggType instanceof HistogramAggregation || aggType instanceof CalendarFieldAggregation ||
        aggType instanceof InternalHistogram || aggType instanceof InternalDateHistogram) {
        return reduceHistogramResults(query, resultAggs);
    }
    if (aggType instanceof RangeAggregation || aggType instanceof InternalRange) {
        return reduceRangeResults(query, resultAggs);
    }
    if (aggType instanceof PercentilesAggregation || aggType instanceof Percentiles) {
        return reducePercentilesResults(query, resultAggs);
    }
    if (aggType instanceof TermsAggregation || aggType instanceof InternalTerms) {
        return reduceTermsResults(query, resultAggs);
    }
    if (aggType instanceof GeohashAggregation || aggType instanceof InternalGeoHashGrid) {
        return reduceGeohashResults(query, resultAggs);
    }
    if (aggType instanceof StatisticsAggregation || aggType instanceof InternalExtendedStats) {
        return reduceStatisticsResults(resultAggs);
    }
    if (aggType instanceof CardinalityAggregation || aggType instanceof InternalCardinality) {
        return reduceCardinalityResults(query, resultAggs);
    }
    throw new VertexiumException("Unhandled aggregation type: " + aggType.getClass().getName());
}