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


Java NumericMetricsAggregation.SingleValue方法代码示例

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


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

示例1: testInBuckets

import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregation; //导入方法依赖的package包/类
public void testInBuckets() throws Exception {

        SearchResponse searchResponse = client().prepareSearch("idx_hll")
                .setQuery(matchAllQuery())
                .addAggregation(AggregationBuilders.terms("tag")
                        .field("tag")
                        .subAggregation(new HyperUniqueSumAggregationBuilder("hyperlog").field("hll")))
                        .execute().actionGet();

        assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L));
        StringTerms stringTerms = searchResponse.getAggregations().get("tag");
        assertThat(stringTerms.getBuckets().size(), equalTo(2));
        NumericMetricsAggregation.SingleValue numericMetricsAggregation = stringTerms.getBucketByKey("crazy").getAggregations().get("hyperlog");
        assertThat(numericMetricsAggregation.value(), equalTo(100.0));
        numericMetricsAggregation = stringTerms.getBucketByKey("mayBeCrazy").getAggregations().get("hyperlog");
        assertThat(numericMetricsAggregation.value(), equalTo(110.0));

    }
 
开发者ID:bazaarvoice,项目名称:elasticsearch-hyperloglog,代码行数:19,代码来源:HyperLogLogPlusAggregationPluginTests.java

示例2: testEmptyAggregation

import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregation; //导入方法依赖的package包/类
public void testEmptyAggregation() throws Exception {

        SearchResponse searchResponse = client().prepareSearch("idx_no_hll")
                .setQuery(matchAllQuery())
                .addAggregation(new HyperUniqueSumAggregationBuilder("hyperlog").field("hll"))
                .execute().actionGet();

        assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L));
        NumericMetricsAggregation.SingleValue numericMetricsAggregation = searchResponse.getAggregations().get("hyperlog");
        assertThat(numericMetricsAggregation, notNullValue());
        assertEquals("expected 0.0 ", "0.0", numericMetricsAggregation.getValueAsString());

    }
 
开发者ID:bazaarvoice,项目名称:elasticsearch-hyperloglog,代码行数:14,代码来源:HyperLogLogPlusAggregationPluginTests.java

示例3: testUniqueSum1

import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregation; //导入方法依赖的package包/类
public void testUniqueSum1() throws Exception {

        SearchResponse searchResponse = client().prepareSearch("idx_hll")
                .setQuery(matchAllQuery())
                .addAggregation(new HyperUniqueSumAggregationBuilder("hyperlog").field("hll"))
                .execute().actionGet();

        assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L));
        NumericMetricsAggregation.SingleValue numericMetricsAggregation = searchResponse.getAggregations().get("hyperlog");
        assertThat(numericMetricsAggregation, notNullValue());
        assertThat(numericMetricsAggregation.value(), equalTo(110.0));

    }
 
开发者ID:bazaarvoice,项目名称:elasticsearch-hyperloglog,代码行数:14,代码来源:HyperLogLogPlusAggregationPluginTests.java

示例4: testUniqueSum2

import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregation; //导入方法依赖的package包/类
public void testUniqueSum2() throws Exception {

        SearchResponse searchResponse = client().prepareSearch("idx_hll")
                .setQuery(termQuery("tag", "crazy"))
                .addAggregation(new HyperUniqueSumAggregationBuilder("hyperlog").field("hll"))
                .execute().actionGet();

        assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L));
        NumericMetricsAggregation.SingleValue numericMetricsAggregation = searchResponse.getAggregations().get("hyperlog");
        assertThat(numericMetricsAggregation, notNullValue());
        assertThat(numericMetricsAggregation.value(), equalTo(100.0));

    }
 
开发者ID:bazaarvoice,项目名称:elasticsearch-hyperloglog,代码行数:14,代码来源:HyperLogLogPlusAggregationPluginTests.java

示例5: handleNumericMetricAggregation

import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregation; //导入方法依赖的package包/类
private  void handleNumericMetricAggregation(List<String> header, List<String> line, Aggregation aggregation) throws CsvExtractorException {
    String name = aggregation.getName();

    if(aggregation instanceof NumericMetricsAggregation.SingleValue){
        if(!header.contains(name)){
            header.add(name);
        }
        line.add(((NumericMetricsAggregation.SingleValue) aggregation).getValueAsString());
    }
    //todo:Numeric MultiValue - Stats,ExtendedStats,Percentile...
    else if(aggregation instanceof NumericMetricsAggregation.MultiValue){
        if(aggregation instanceof Stats) {
            String[] statsHeaders = new String[]{"count", "sum", "avg", "min", "max"};
            boolean isExtendedStats = aggregation instanceof ExtendedStats;
            if(isExtendedStats){
                String[] extendedHeaders = new String[]{"sumOfSquares", "variance", "stdDeviation"};
                statsHeaders = Util.concatStringsArrays(statsHeaders,extendedHeaders);
            }
            mergeHeadersWithPrefix(header, name, statsHeaders);
            Stats stats = (Stats) aggregation;
            line.add(stats.getCountAsString());
            line.add(stats.getSumAsString());
            line.add(stats.getAvgAsString());
            line.add(stats.getMinAsString());
            line.add(stats.getMaxAsString());
            if(isExtendedStats){
                ExtendedStats extendedStats = (ExtendedStats) aggregation;
                line.add(extendedStats.getSumOfSquaresAsString());
                line.add(extendedStats.getVarianceAsString());
                line.add(extendedStats.getStdDeviationAsString());
            }
        }
        else if( aggregation instanceof Percentiles){
            String[] percentileHeaders = new String[]{"1.0", "5.0", "25.0", "50.0", "75.0", "95.0", "99.0"};
            mergeHeadersWithPrefix(header, name, percentileHeaders);
            Percentiles percentiles = (Percentiles) aggregation;
            line.add(percentiles.percentileAsString(1.0));
            line.add(percentiles.percentileAsString(5.0));
            line.add(percentiles.percentileAsString(25.0));
            line.add(percentiles.percentileAsString(50.0));
            line.add(percentiles.percentileAsString(75));
            line.add(percentiles.percentileAsString(95.0));
            line.add(percentiles.percentileAsString(99.0));
        }
        else {
            throw new CsvExtractorException("unknown NumericMetricsAggregation.MultiValue:" + aggregation.getClass());
        }

    }
    else {
        throw new CsvExtractorException("unknown NumericMetricsAggregation" + aggregation.getClass());
    }
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:54,代码来源:CSVResultsExtractor.java

示例6: handleNumericMetricAggregation

import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregation; //导入方法依赖的package包/类
private void handleNumericMetricAggregation(List<String> header, List<Object> line, Aggregation aggregation) throws ObjectResultsExtractException {
    String name = aggregation.getName();

    if (aggregation instanceof NumericMetricsAggregation.SingleValue) {
        if (!header.contains(name)) {
            header.add(name);
        }
        line.add(((NumericMetricsAggregation.SingleValue) aggregation).value());
    }
    //todo:Numeric MultiValue - Stats,ExtendedStats,Percentile...
    else if (aggregation instanceof NumericMetricsAggregation.MultiValue) {
        if (aggregation instanceof Stats) {
            String[] statsHeaders = new String[]{"count", "sum", "avg", "min", "max"};
            boolean isExtendedStats = aggregation instanceof ExtendedStats;
            if (isExtendedStats) {
                String[] extendedHeaders = new String[]{"sumOfSquares", "variance", "stdDeviation"};
                statsHeaders = Util.concatStringsArrays(statsHeaders, extendedHeaders);
            }
            mergeHeadersWithPrefix(header, name, statsHeaders);
            Stats stats = (Stats) aggregation;
            line.add(stats.getCount());
            line.add(stats.getSum());
            line.add(stats.getAvg());
            line.add(stats.getMin());
            line.add(stats.getMax());
            if (isExtendedStats) {
                ExtendedStats extendedStats = (ExtendedStats) aggregation;
                line.add(extendedStats.getSumOfSquares());
                line.add(extendedStats.getVariance());
                line.add(extendedStats.getStdDeviation());
            }
        } else if (aggregation instanceof Percentiles) {
            String[] percentileHeaders = new String[]{"1.0", "5.0", "25.0", "50.0", "75.0", "95.0", "99.0"};
            mergeHeadersWithPrefix(header, name, percentileHeaders);
            Percentiles percentiles = (Percentiles) aggregation;
            line.add(percentiles.percentile(1.0));
            line.add(percentiles.percentile(5.0));
            line.add(percentiles.percentile(25.0));
            line.add(percentiles.percentile(50.0));
            line.add(percentiles.percentile(75));
            line.add(percentiles.percentile(95.0));
            line.add(percentiles.percentile(99.0));
        } else {
            throw new ObjectResultsExtractException("unknown NumericMetricsAggregation.MultiValue:" + aggregation.getClass());
        }

    } else {
        throw new ObjectResultsExtractException("unknown NumericMetricsAggregation" + aggregation.getClass());
    }
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:51,代码来源:ObjectResultsExtractor.java

示例7: handleNumericMetricAggregation

import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregation; //导入方法依赖的package包/类
private  void handleNumericMetricAggregation(List<String> header, List<String> line, Aggregation aggregation) throws CsvExtractorException {
    String name = aggregation.getName();

    if(aggregation instanceof NumericMetricsAggregation.SingleValue){
        if(!header.contains(name)){
            header.add(name);
        }
        NumericMetricsAggregation.SingleValue agg = (NumericMetricsAggregation.SingleValue) aggregation;
        line.add(!Double.isInfinite(agg.value()) ? agg.getValueAsString() : "null");
    }
    //todo:Numeric MultiValue - Stats,ExtendedStats,Percentile...
    else if(aggregation instanceof NumericMetricsAggregation.MultiValue){
        if(aggregation instanceof Stats) {
            String[] statsHeaders = new String[]{"count", "sum", "avg", "min", "max"};
            boolean isExtendedStats = aggregation instanceof ExtendedStats;
            if(isExtendedStats){
                String[] extendedHeaders = new String[]{"sumOfSquares", "variance", "stdDeviation"};
                statsHeaders = Util.concatStringsArrays(statsHeaders,extendedHeaders);
            }
            mergeHeadersWithPrefix(header, name, statsHeaders);
            Stats stats = (Stats) aggregation;
            line.add(String.valueOf(stats.getCount()));
            line.add(stats.getSumAsString());
            line.add(stats.getAvgAsString());
            line.add(stats.getMinAsString());
            line.add(stats.getMaxAsString());
            if(isExtendedStats){
                ExtendedStats extendedStats = (ExtendedStats) aggregation;
                line.add(extendedStats.getSumOfSquaresAsString());
                line.add(extendedStats.getVarianceAsString());
                line.add(extendedStats.getStdDeviationAsString());
            }
        }
        else if( aggregation instanceof Percentiles){
            String[] percentileHeaders = new String[]{"1.0", "5.0", "25.0", "50.0", "75.0", "95.0", "99.0"};
            mergeHeadersWithPrefix(header, name, percentileHeaders);
            Percentiles percentiles = (Percentiles) aggregation;
            line.add(percentiles.percentileAsString(1.0));
            line.add(percentiles.percentileAsString(5.0));
            line.add(percentiles.percentileAsString(25.0));
            line.add(percentiles.percentileAsString(50.0));
            line.add(percentiles.percentileAsString(75));
            line.add(percentiles.percentileAsString(95.0));
            line.add(percentiles.percentileAsString(99.0));
        }
        else {
            throw new CsvExtractorException("unknown NumericMetricsAggregation.MultiValue:" + aggregation.getClass());
        }

    }
    else {
        throw new CsvExtractorException("unknown NumericMetricsAggregation" + aggregation.getClass());
    }
}
 
开发者ID:NLPchina,项目名称:elasticsearch-sql,代码行数:55,代码来源:CSVResultsExtractor.java


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