use of org.elasticsearch.search.aggregations.bucket.missing.Missing in project elasticsearch by elastic.
the class ExtendedStatsIT method testEmptySubAggregation.
public void testEmptySubAggregation() {
SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()).addAggregation(terms("value").field("value").subAggregation(missing("values").field("values").subAggregation(extendedStats("stats").field("value")))).execute().actionGet();
assertHitCount(searchResponse, 10);
Terms terms = searchResponse.getAggregations().get("value");
assertThat(terms, notNullValue());
assertThat(terms.getBuckets().size(), equalTo(10));
for (Terms.Bucket bucket : terms.getBuckets()) {
assertThat(bucket.getDocCount(), equalTo(1L));
Missing missing = bucket.getAggregations().get("values");
assertThat(missing, notNullValue());
assertThat(missing.getDocCount(), equalTo(0L));
ExtendedStats stats = missing.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));
}
}
use of org.elasticsearch.search.aggregations.bucket.missing.Missing in project elasticsearch by elastic.
the class MissingIT method testPartiallyUnmapped.
public void testPartiallyUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("idx", "unmapped_idx").addAggregation(missing("missing_tag").field("tag")).execute().actionGet();
assertSearchResponse(response);
Missing missing = response.getAggregations().get("missing_tag");
assertThat(missing, notNullValue());
assertThat(missing.getName(), equalTo("missing_tag"));
assertThat(missing.getDocCount(), equalTo((long) numDocsMissing + numDocsUnmapped));
}
use of org.elasticsearch.search.aggregations.bucket.missing.Missing in project elasticsearch by elastic.
the class MissingIT method testUnmapped.
public void testUnmapped() throws Exception {
SearchResponse response = client().prepareSearch("unmapped_idx").addAggregation(missing("missing_tag").field("tag")).execute().actionGet();
assertSearchResponse(response);
Missing missing = response.getAggregations().get("missing_tag");
assertThat(missing, notNullValue());
assertThat(missing.getName(), equalTo("missing_tag"));
assertThat(missing.getDocCount(), equalTo((long) numDocsUnmapped));
}
use of org.elasticsearch.search.aggregations.bucket.missing.Missing in project elasticsearch by elastic.
the class ShardReduceIT method testGlobalWithFilterWithMissing.
public void testGlobalWithFilterWithMissing() throws Exception {
SearchResponse response = client().prepareSearch("idx").setQuery(QueryBuilders.matchAllQuery()).addAggregation(global("global").subAggregation(filter("filter", QueryBuilders.matchAllQuery()).subAggregation(missing("missing").field("foobar").subAggregation(dateHistogram("histo").field("date").dateHistogramInterval(DateHistogramInterval.DAY).minDocCount(0))))).execute().actionGet();
assertSearchResponse(response);
Global global = response.getAggregations().get("global");
Filter filter = global.getAggregations().get("filter");
Missing missing = filter.getAggregations().get("missing");
Histogram histo = missing.getAggregations().get("histo");
assertThat(histo.getBuckets().size(), equalTo(4));
}
Aggregations