• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ExtendedStats类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats的典型用法代码示例。如果您正苦于以下问题:Java ExtendedStats类的具体用法?Java ExtendedStats怎么用?Java ExtendedStats使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ExtendedStats类属于org.elasticsearch.search.aggregations.metrics.stats.extended包,在下文中一共展示了ExtendedStats类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: reduceStatisticsResults

import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats; //导入依赖的package包/类
private static StatisticsResult reduceStatisticsResults(List<Aggregation> aggs) {
    List<StatisticsResult> results = new ArrayList<>();
    for (Aggregation agg : aggs) {
        if (agg instanceof ExtendedStats) {
            ExtendedStats extendedStats = (ExtendedStats) agg;
            long count = extendedStats.getCount();
            double sum = extendedStats.getSum();
            double min = extendedStats.getMin();
            double max = extendedStats.getMax();
            double standardDeviation = extendedStats.getStdDeviation();
            results.add(new StatisticsResult(count, sum, min, max, standardDeviation));
        } else {
            throw new MemgraphException("Aggregation is not a statistics: " + agg.getClass().getName());
        }
    }
    return StatisticsResult.combine(results);
}
 
开发者ID:mware-solutions,项目名称:memory-graph,代码行数:18,代码来源:ElasticsearchGraphQueryIterable.java


示例2: testUnmapped

import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats; //导入依赖的package包/类
@Override
public void testUnmapped() throws Exception {
    SearchResponse searchResponse = client().prepareSearch("idx_unmapped")
            .setQuery(matchAllQuery())
            .addAggregation(extendedStats("stats").field("value"))
            .execute().actionGet();

    assertThat(searchResponse.getHits().getTotalHits(), equalTo(0L));

    ExtendedStats stats = searchResponse.getAggregations().get("stats");
    assertThat(stats, notNullValue());
    assertThat(stats.getName(), equalTo("stats"));
    assertThat(stats.getAvg(), equalTo(Double.NaN));
    assertThat(stats.getMin(), equalTo(Double.POSITIVE_INFINITY));
    assertThat(stats.getMax(), equalTo(Double.NEGATIVE_INFINITY));
    assertThat(stats.getSum(), equalTo(0.0));
    assertThat(stats.getCount(), equalTo(0L));
    assertThat(stats.getSumOfSquares(), equalTo(0.0));
    assertThat(stats.getVariance(), equalTo(Double.NaN));
    assertThat(stats.getStdDeviation(), equalTo(Double.NaN));
    assertThat(Double.isNaN(stats.getStdDeviationBound(ExtendedStats.Bounds.UPPER)), is(true));
    assertThat(Double.isNaN(stats.getStdDeviationBound(ExtendedStats.Bounds.LOWER)), is(true));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:ExtendedStatsIT.java


示例3: testPartiallyUnmapped

import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats; //导入依赖的package包/类
public void testPartiallyUnmapped() {
    double sigma = randomDouble() * 5;
    ExtendedStats s1 = client().prepareSearch("idx")
            .addAggregation(extendedStats("stats").field("value").sigma(sigma)).get()
            .getAggregations().get("stats");
    ExtendedStats s2 = client().prepareSearch("idx", "idx_unmapped")
            .addAggregation(extendedStats("stats").field("value").sigma(sigma)).get()
            .getAggregations().get("stats");
    assertEquals(s1.getAvg(), s2.getAvg(), 1e-10);
    assertEquals(s1.getCount(), s2.getCount());
    assertEquals(s1.getMin(), s2.getMin(), 0d);
    assertEquals(s1.getMax(), s2.getMax(), 0d);
    assertEquals(s1.getStdDeviation(), s2.getStdDeviation(), 1e-10);
    assertEquals(s1.getSumOfSquares(), s2.getSumOfSquares(), 1e-10);
    assertEquals(s1.getStdDeviationBound(Bounds.LOWER), s2.getStdDeviationBound(Bounds.LOWER), 1e-10);
    assertEquals(s1.getStdDeviationBound(Bounds.UPPER), s2.getStdDeviationBound(Bounds.UPPER), 1e-10);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:ExtendedStatsIT.java


示例4: testSingleValuedField

import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats; //导入依赖的package包/类
@Override
public void testSingleValuedField() throws Exception {
    double sigma = randomDouble() * randomIntBetween(1, 10);
    SearchResponse searchResponse = client().prepareSearch("idx")
            .setQuery(matchAllQuery())
            .addAggregation(extendedStats("stats").field("value").sigma(sigma))
            .execute().actionGet();

    assertHitCount(searchResponse, 10);

    ExtendedStats stats = searchResponse.getAggregations().get("stats");
    assertThat(stats, notNullValue());
    assertThat(stats.getName(), equalTo("stats"));
    assertThat(stats.getAvg(), equalTo((double) (1+2+3+4+5+6+7+8+9+10) / 10));
    assertThat(stats.getMin(), equalTo(1.0));
    assertThat(stats.getMax(), equalTo(10.0));
    assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10));
    assertThat(stats.getCount(), equalTo(10L));
    assertThat(stats.getSumOfSquares(), equalTo((double) 1+4+9+16+25+36+49+64+81+100));
    assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)));
    assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)));
    checkUpperLowerBounds(stats, sigma);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:ExtendedStatsIT.java


示例5: testSingleValuedFieldDefaultSigma

import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats; //导入依赖的package包/类
public void testSingleValuedFieldDefaultSigma() throws Exception {
    // Same as previous test, but uses a default value for sigma

    SearchResponse searchResponse = client().prepareSearch("idx")
            .setQuery(matchAllQuery())
            .addAggregation(extendedStats("stats").field("value"))
            .execute().actionGet();

    assertHitCount(searchResponse, 10);

    ExtendedStats stats = searchResponse.getAggregations().get("stats");
    assertThat(stats, notNullValue());
    assertThat(stats.getName(), equalTo("stats"));
    assertThat(stats.getAvg(), equalTo((double) (1+2+3+4+5+6+7+8+9+10) / 10));
    assertThat(stats.getMin(), equalTo(1.0));
    assertThat(stats.getMax(), equalTo(10.0));
    assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10));
    assertThat(stats.getCount(), equalTo(10L));
    assertThat(stats.getSumOfSquares(), equalTo((double) 1+4+9+16+25+36+49+64+81+100));
    assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)));
    assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)));
    checkUpperLowerBounds(stats, 2);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:ExtendedStatsIT.java


示例6: testSingleValuedFieldPartiallyUnmapped

import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats; //导入依赖的package包/类
@Override
public void testSingleValuedFieldPartiallyUnmapped() throws Exception {
    double sigma = randomDouble() * randomIntBetween(1, 10);
    SearchResponse searchResponse = client().prepareSearch("idx", "idx_unmapped")
            .setQuery(matchAllQuery())
            .addAggregation(extendedStats("stats").field("value").sigma(sigma))
            .execute().actionGet();

    assertHitCount(searchResponse, 10);

    ExtendedStats stats = searchResponse.getAggregations().get("stats");
    assertThat(stats, notNullValue());
    assertThat(stats.getName(), equalTo("stats"));
    assertThat(stats.getAvg(), equalTo((double) (1+2+3+4+5+6+7+8+9+10) / 10));
    assertThat(stats.getMin(), equalTo(1.0));
    assertThat(stats.getMax(), equalTo(10.0));
    assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10));
    assertThat(stats.getCount(), equalTo(10L));
    assertThat(stats.getSumOfSquares(), equalTo((double) 1+4+9+16+25+36+49+64+81+100));
    assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)));
    assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)));
    checkUpperLowerBounds(stats, sigma);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:ExtendedStatsIT.java


示例7: testMultiValuedField

import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats; //导入依赖的package包/类
@Override
public void testMultiValuedField() throws Exception {
    double sigma = randomDouble() * randomIntBetween(1, 10);
    SearchResponse searchResponse = client().prepareSearch("idx")
            .setQuery(matchAllQuery())
            .addAggregation(extendedStats("stats").field("values").sigma(sigma))
            .execute().actionGet();

    assertHitCount(searchResponse, 10);

    ExtendedStats stats = searchResponse.getAggregations().get("stats");
    assertThat(stats, notNullValue());
    assertThat(stats.getName(), equalTo("stats"));
    assertThat(stats.getAvg(), equalTo((double) (2+3+4+5+6+7+8+9+10+11+3+4+5+6+7+8+9+10+11+12) / 20));
    assertThat(stats.getMin(), equalTo(2.0));
    assertThat(stats.getMax(), equalTo(12.0));
    assertThat(stats.getSum(), equalTo((double) 2+3+4+5+6+7+8+9+10+11+3+4+5+6+7+8+9+10+11+12));
    assertThat(stats.getCount(), equalTo(20L));
    assertThat(stats.getSumOfSquares(), equalTo((double) 4+9+16+25+36+49+64+81+100+121+9+16+25+36+49+64+81+100+121+144));
    assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)));
    assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)));
    checkUpperLowerBounds(stats, sigma);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:ExtendedStatsIT.java


示例8: reduceStatisticsResults

import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats; //导入依赖的package包/类
private static StatisticsResult reduceStatisticsResults(List<Aggregation> aggs) {
    List<StatisticsResult> results = new ArrayList<>();
    for (Aggregation agg : aggs) {
        if (agg instanceof ExtendedStats) {
            ExtendedStats extendedStats = (ExtendedStats) agg;
            long count = extendedStats.getCount();
            double sum = extendedStats.getSum();
            double min = extendedStats.getMin();
            double max = extendedStats.getMax();
            double standardDeviation = extendedStats.getStdDeviation();
            results.add(new StatisticsResult(count, sum, min, max, standardDeviation));
        } else {
            throw new VertexiumException("Aggregation is not a statistics: " + agg.getClass().getName());
        }
    }
    return StatisticsResult.combine(results);
}
 
开发者ID:visallo,项目名称:vertexium,代码行数:18,代码来源:ElasticsearchGraphQueryIterable.java


示例9: parse

import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats; //导入依赖的package包/类
@Override
public FieldMetadata parse(FieldInfo info, ExtendedStats stats, int valuesPerDocument) {
	long from = Math.round(stats.getMin());
	long to = Math.round(stats.getMax());

	String[] esPatterns = info.getJson().path(FORMAT_PROP).asText(MetadataConstants.DEFAULT_DATE_PATTERN).split(DATE_SEPARATOR);
	String pattern = jodaToJDK(info, esPatterns);
	Instant fromInstant = Instant.ofEpochMilli(from);
	Instant toInstant = Instant.ofEpochMilli(to);
	ChronoUnit unit = calculateTimeStep(fromInstant, toInstant, stats.getCount());

	if(pattern != null) {
		long increment = unit.between(fromInstant, toInstant) / stats.getCount();
		return new DateFieldMetadata(info.getFullPath(), valuesPerDocument, fromInstant, toInstant, increment, unit, pattern);
	} else {
		return jodaToNumericUnit(info.getFullPath(), valuesPerDocument, fromInstant, toInstant, unit, esPatterns);
	}
}
 
开发者ID:kucera-jan-cz,项目名称:esBench,代码行数:19,代码来源:DateStatsAnalyzer.java


示例10: collectNumericData

import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats; //导入依赖的package包/类
private <T extends FieldMetadata> List<FieldMetadata> collectNumericData(Collection<FieldInfo> fields, ExtendedStatsAnalyzer<T> parser) {
	if(fields.isEmpty()) {
		return Collections.emptyList();
	}
	List<FieldMetadata> metadata = new ArrayList<>(fields.size());
	SearchRequestBuilder builder = createNumericSearchBuilder(fields);
	SearchResponse response = client.search(builder.request()).actionGet();
	for(FieldInfo info : fields) {
		InternalFilter filter = getAggregation(response, info, FILTER_AGG);
		ExtendedStats stats = (ExtendedStats) filter.getAggregations().get(EXTENDED_STATS_AGG + info.getFullPath());
		LOGGER.debug("Field {} total: {} MAX: {} MIN: {}", info.getFullPath(), stats.getCount(), stats.getMaxAsString(), stats.getMinAsString());
		if(stats.getCount() <= ZERO_ITEMS) {
			continue;
		}
		int valuesPerDocument = valuesPerDoc(response, filter, stats);
		FieldMetadata meta = parser.parse(info, stats, valuesPerDocument);
		LOGGER.debug("Registering metadata: {}", meta);
		metadata.add(meta);
	}
	return metadata;
}
 
开发者ID:kucera-jan-cz,项目名称:esBench,代码行数:22,代码来源:FieldAnalyzer.java


示例11: testSortingByMulValMetric

import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats; //导入依赖的package包/类
@Test
public void testSortingByMulValMetric() {
  String termsColors = "colors", stats = "stats";
  srb =
      client.prepareSearch("cars").addAggregation(
          AggregationBuilders.terms(termsColors).field("color")
              .order(Order.aggregation("stats.variance", true))
              .subAggregation(AggregationBuilders.extendedStats(stats).field("price")));

  SearchResponse response = srb.execute().actionGet();

  // read agg
  Terms colorsTerms = (Terms) response.getAggregations().get("colors");
  colorsTerms.getBuckets().forEach(
      bucket -> {
        double variancePrice =
            ((ExtendedStats) bucket.getAggregations().get(stats)).getVariance();
        System.out.println(String.format("Key: %s, Doc count: %d, Variance: %f", bucket.getKey(),
            bucket.getDocCount(), variancePrice));
      });
}
 
开发者ID:destiny1020,项目名称:elasticsearch-java-client-examples,代码行数:22,代码来源:SortingMulValBucketsExamples.java


示例12: testRandomDoubles

import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats; //导入依赖的package包/类
public void testRandomDoubles() throws IOException {
    MappedFieldType ft =
        new NumberFieldMapper.NumberFieldType(NumberFieldMapper.NumberType.DOUBLE);
    ft.setName("field");
    final ExtendedSimpleStatsAggregator expected = new ExtendedSimpleStatsAggregator();
    testCase(ft,
        iw -> {
            int numDocs = randomIntBetween(10, 50);
            for (int i = 0; i < numDocs; i++) {
                Document doc = new Document();
                int numValues = randomIntBetween(1, 5);
                for (int j = 0; j < numValues; j++) {
                    double value = randomDoubleBetween(-100d, 100d, true);
                    long valueAsLong = NumericUtils.doubleToSortableLong(value);
                    doc.add(new SortedNumericDocValuesField("field", valueAsLong));
                    expected.add(value);
                }
                iw.addDocument(doc);
            }
        },
        stats -> {
            assertEquals(expected.count, stats.getCount(), 0);
            assertEquals(expected.sum, stats.getSum(), TOLERANCE);
            assertEquals(expected.min, stats.getMin(), 0);
            assertEquals(expected.max, stats.getMax(), 0);
            assertEquals(expected.sum / expected.count, stats.getAvg(), TOLERANCE);
            assertEquals(expected.sumOfSqrs, stats.getSumOfSquares(), TOLERANCE);
            assertEquals(expected.stdDev(), stats.getStdDeviation(), TOLERANCE);
            assertEquals(expected.variance(), stats.getVariance(), TOLERANCE);
            assertEquals(expected.stdDevBound(ExtendedStats.Bounds.LOWER, stats.getSigma()),
                stats.getStdDeviationBound(ExtendedStats.Bounds.LOWER), TOLERANCE);
            assertEquals(expected.stdDevBound(ExtendedStats.Bounds.UPPER, stats.getSigma()),
                stats.getStdDeviationBound(ExtendedStats.Bounds.UPPER), TOLERANCE);
        }
    );
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:37,代码来源:ExtendedStatsAggregatorTests.java


示例13: testRandomLongs

import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats; //导入依赖的package包/类
public void testRandomLongs() throws IOException {
    MappedFieldType ft =
        new NumberFieldMapper.NumberFieldType(NumberFieldMapper.NumberType.LONG);
    ft.setName("field");
    final ExtendedSimpleStatsAggregator expected = new ExtendedSimpleStatsAggregator();
    testCase(ft,
        iw -> {
            int numDocs = randomIntBetween(10, 50);
            for (int i = 0; i < numDocs; i++) {
                Document doc = new Document();
                int numValues = randomIntBetween(1, 5);
                for (int j = 0; j < numValues; j++) {
                    long value = randomIntBetween(-100, 100);
                    doc.add(new SortedNumericDocValuesField("field", value));
                    expected.add(value);
                }
                iw.addDocument(doc);
            }
        },
        stats -> {
            assertEquals(expected.count, stats.getCount(), 0);
            assertEquals(expected.sum, stats.getSum(), TOLERANCE);
            assertEquals(expected.min, stats.getMin(), 0);
            assertEquals(expected.max, stats.getMax(), 0);
            assertEquals(expected.sum / expected.count, stats.getAvg(), TOLERANCE);
            assertEquals(expected.sumOfSqrs, stats.getSumOfSquares(), TOLERANCE);
            assertEquals(expected.stdDev(), stats.getStdDeviation(), TOLERANCE);
            assertEquals(expected.variance(), stats.getVariance(), TOLERANCE);
            assertEquals(expected.stdDevBound(ExtendedStats.Bounds.LOWER, stats.getSigma()),
                stats.getStdDeviationBound(ExtendedStats.Bounds.LOWER), TOLERANCE);
            assertEquals(expected.stdDevBound(ExtendedStats.Bounds.UPPER, stats.getSigma()),
                stats.getStdDeviationBound(ExtendedStats.Bounds.UPPER), TOLERANCE);
        }
    );
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:36,代码来源:ExtendedStatsAggregatorTests.java


示例14: stdDevBound

import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats; //导入依赖的package包/类
double stdDevBound(ExtendedStats.Bounds bounds, double sigma) {
    if (bounds == ExtendedStats.Bounds.UPPER) {
        return (sum / count) + (Math.sqrt(variance()) * sigma);
    } else {
        return (sum / count) - (Math.sqrt(variance()) * sigma);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:ExtendedStatsAggregatorTests.java


示例15: testEmptyAggregation

import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats; //导入依赖的package包/类
@Override
public void testEmptyAggregation() throws Exception {
    SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
            .setQuery(matchAllQuery())
            .addAggregation(
                    histogram("histo").field("value").interval(1L).minDocCount(0).subAggregation(extendedStats("stats").field("value")))
            .execute().actionGet();

    assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L));
    Histogram histo = searchResponse.getAggregations().get("histo");
    assertThat(histo, notNullValue());
    Histogram.Bucket bucket = histo.getBuckets().get(1);
    assertThat(bucket, notNullValue());

    ExtendedStats stats = bucket.getAggregations().get("stats");
    assertThat(stats, notNullValue());
    assertThat(stats.getName(), equalTo("stats"));
    assertThat(stats.getSumOfSquares(), equalTo(0.0));
    assertThat(stats.getCount(), equalTo(0L));
    assertThat(stats.getSum(), equalTo(0.0));
    assertThat(stats.getMin(), equalTo(Double.POSITIVE_INFINITY));
    assertThat(stats.getMax(), equalTo(Double.NEGATIVE_INFINITY));
    assertThat(Double.isNaN(stats.getStdDeviation()), is(true));
    assertThat(Double.isNaN(stats.getAvg()), is(true));
    assertThat(Double.isNaN(stats.getStdDeviationBound(ExtendedStats.Bounds.UPPER)), is(true));
    assertThat(Double.isNaN(stats.getStdDeviationBound(ExtendedStats.Bounds.LOWER)), is(true));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:28,代码来源:ExtendedStatsIT.java


示例16: testSingleValuedField_WithFormatter

import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats; //导入依赖的package包/类
public void testSingleValuedField_WithFormatter() throws Exception {
    double sigma = randomDouble() * randomIntBetween(1, 10);
    SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery())
            .addAggregation(extendedStats("stats").format("0000.0").field("value").sigma(sigma)).execute().actionGet();

    assertHitCount(searchResponse, 10);

    ExtendedStats stats = searchResponse.getAggregations().get("stats");
    assertThat(stats, notNullValue());
    assertThat(stats.getName(), equalTo("stats"));
    assertThat(stats.getAvg(), equalTo((double) (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10) / 10));
    assertThat(stats.getAvgAsString(), equalTo("0005.5"));
    assertThat(stats.getMin(), equalTo(1.0));
    assertThat(stats.getMinAsString(), equalTo("0001.0"));
    assertThat(stats.getMax(), equalTo(10.0));
    assertThat(stats.getMaxAsString(), equalTo("0010.0"));
    assertThat(stats.getSum(), equalTo((double) 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10));
    assertThat(stats.getSumAsString(), equalTo("0055.0"));
    assertThat(stats.getCount(), equalTo(10L));
    assertThat(stats.getCountAsString(), equalTo("0010.0"));
    assertThat(stats.getSumOfSquares(), equalTo((double) 1 + 4 + 9 + 16 + 25 + 36 + 49 + 64 + 81 + 100));
    assertThat(stats.getSumOfSquaresAsString(), equalTo("0385.0"));
    assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)));
    assertThat(stats.getVarianceAsString(), equalTo("0008.2"));
    assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)));
    assertThat(stats.getStdDeviationAsString(), equalTo("0002.9"));
    checkUpperLowerBounds(stats, sigma);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:ExtendedStatsIT.java


示例17: testSingleValuedFieldWithValueScript

import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats; //导入依赖的package包/类
@Override
public void testSingleValuedFieldWithValueScript() throws Exception {
    double sigma = randomDouble() * randomIntBetween(1, 10);
    SearchResponse searchResponse = client().prepareSearch("idx")
            .setQuery(matchAllQuery())
            .addAggregation(
                    extendedStats("stats")
                            .field("value")
                            .script(new Script(ScriptType.INLINE,
                                AggregationTestScriptsPlugin.NAME, "_value + 1", Collections.emptyMap()))
                            .sigma(sigma))
            .execute().actionGet();

    assertHitCount(searchResponse, 10);

    ExtendedStats stats = searchResponse.getAggregations().get("stats");
    assertThat(stats, notNullValue());
    assertThat(stats.getName(), equalTo("stats"));
    assertThat(stats.getAvg(), equalTo((double) (2+3+4+5+6+7+8+9+10+11) / 10));
    assertThat(stats.getMin(), equalTo(2.0));
    assertThat(stats.getMax(), equalTo(11.0));
    assertThat(stats.getSum(), equalTo((double) 2+3+4+5+6+7+8+9+10+11));
    assertThat(stats.getCount(), equalTo(10L));
    assertThat(stats.getSumOfSquares(), equalTo((double) 4+9+16+25+36+49+64+81+100+121));
    assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));
    assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));
    checkUpperLowerBounds(stats, sigma);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:ExtendedStatsIT.java


示例18: testSingleValuedFieldWithValueScriptWithParams

import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats; //导入依赖的package包/类
@Override
public void testSingleValuedFieldWithValueScriptWithParams() throws Exception {
    Map<String, Object> params = new HashMap<>();
    params.put("inc", 1);
    double sigma = randomDouble() * randomIntBetween(1, 10);
    SearchResponse searchResponse = client().prepareSearch("idx")
            .setQuery(matchAllQuery())
            .addAggregation(
                    extendedStats("stats")
                            .field("value")
                            .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value + inc", params))
                            .sigma(sigma))
            .execute().actionGet();

    assertHitCount(searchResponse, 10);

    ExtendedStats stats = searchResponse.getAggregations().get("stats");
    assertThat(stats, notNullValue());
    assertThat(stats.getName(), equalTo("stats"));
    assertThat(stats.getAvg(), equalTo((double) (2+3+4+5+6+7+8+9+10+11) / 10));
    assertThat(stats.getMin(), equalTo(2.0));
    assertThat(stats.getMax(), equalTo(11.0));
    assertThat(stats.getSum(), equalTo((double) 2+3+4+5+6+7+8+9+10+11));
    assertThat(stats.getCount(), equalTo(10L));
    assertThat(stats.getSumOfSquares(), equalTo((double) 4+9+16+25+36+49+64+81+100+121));
    assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));
    assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));
    checkUpperLowerBounds(stats, sigma);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:30,代码来源:ExtendedStatsIT.java


示例19: testMultiValuedFieldWithValueScript

import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats; //导入依赖的package包/类
@Override
public void testMultiValuedFieldWithValueScript() throws Exception {
    double sigma = randomDouble() * randomIntBetween(1, 10);
    SearchResponse searchResponse = client().prepareSearch("idx")
            .setQuery(matchAllQuery())
            .addAggregation(
                    extendedStats("stats")
                            .field("values")
                            .script(new Script(ScriptType.INLINE,
                                AggregationTestScriptsPlugin.NAME, "_value - 1", Collections.emptyMap()))
                            .sigma(sigma))
            .execute().actionGet();

    assertHitCount(searchResponse, 10);

    ExtendedStats stats = searchResponse.getAggregations().get("stats");
    assertThat(stats, notNullValue());
    assertThat(stats.getName(), equalTo("stats"));
    assertThat(stats.getAvg(), equalTo((double) (1+2+3+4+5+6+7+8+9+10+2+3+4+5+6+7+8+9+10+11) / 20));
    assertThat(stats.getMin(), equalTo(1.0));
    assertThat(stats.getMax(), equalTo(11.0));
    assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10+2+3+4+5+6+7+8+9+10+11));
    assertThat(stats.getCount(), equalTo(20L));
    assertThat(stats.getSumOfSquares(), equalTo((double) 1+4+9+16+25+36+49+64+81+100+4+9+16+25+36+49+64+81+100+121));
    assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 11)));
    assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 11)));
    checkUpperLowerBounds(stats, sigma);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:ExtendedStatsIT.java


示例20: testMultiValuedFieldWithValueScriptWithParams

import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats; //导入依赖的package包/类
@Override
public void testMultiValuedFieldWithValueScriptWithParams() throws Exception {
    Map<String, Object> params = new HashMap<>();
    params.put("dec", 1);
    double sigma = randomDouble() * randomIntBetween(1, 10);
    SearchResponse searchResponse = client().prepareSearch("idx")
            .setQuery(matchAllQuery())
            .addAggregation(
                    extendedStats("stats")
                            .field("values")
                            .script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "_value - dec", params))
                            .sigma(sigma))
            .get();

    assertHitCount(searchResponse, 10);

    ExtendedStats stats = searchResponse.getAggregations().get("stats");
    assertThat(stats, notNullValue());
    assertThat(stats.getName(), equalTo("stats"));
    assertThat(stats.getAvg(), equalTo((double) (1+2+3+4+5+6+7+8+9+10+2+3+4+5+6+7+8+9+10+11) / 20));
    assertThat(stats.getMin(), equalTo(1.0));
    assertThat(stats.getMax(), equalTo(11.0));
    assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10+2+3+4+5+6+7+8+9+10+11));
    assertThat(stats.getCount(), equalTo(20L));
    assertThat(stats.getSumOfSquares(), equalTo((double) 1+4+9+16+25+36+49+64+81+100+4+9+16+25+36+49+64+81+100+121));
    assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 11)));
    assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 11)));
    checkUpperLowerBounds(stats, sigma);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:30,代码来源:ExtendedStatsIT.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PropertyEventDispatcher类代码示例发布时间:2022-05-22
下一篇:
Java PackageFragment类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap