Search in sources :

Example 16 with IncludeExclude

use of org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude in project elasticsearch by elastic.

the class ExtendedStatsBucketIT method testNoBuckets.

public void testNoBuckets() throws Exception {
    SearchResponse response = client().prepareSearch("idx").addAggregation(terms("terms").field("tag").includeExclude(new IncludeExclude(null, "tag.*")).subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME))).addAggregation(extendedStatsBucket("extended_stats_bucket", "terms>sum")).execute().actionGet();
    assertSearchResponse(response);
    Terms terms = response.getAggregations().get("terms");
    assertThat(terms, notNullValue());
    assertThat(terms.getName(), equalTo("terms"));
    List<Terms.Bucket> buckets = terms.getBuckets();
    assertThat(buckets.size(), equalTo(0));
    ExtendedStatsBucket extendedStatsBucketValue = response.getAggregations().get("extended_stats_bucket");
    assertThat(extendedStatsBucketValue, notNullValue());
    assertThat(extendedStatsBucketValue.getName(), equalTo("extended_stats_bucket"));
    assertThat(extendedStatsBucketValue.getAvg(), equalTo(Double.NaN));
}
Also used : ExtendedStatsBucket(org.elasticsearch.search.aggregations.pipeline.bucketmetrics.stats.extended.ExtendedStatsBucket) Bucket(org.elasticsearch.search.aggregations.bucket.histogram.Histogram.Bucket) PipelineAggregatorBuilders.extendedStatsBucket(org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.extendedStatsBucket) ExtendedStatsBucket(org.elasticsearch.search.aggregations.pipeline.bucketmetrics.stats.extended.ExtendedStatsBucket) IncludeExclude(org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude) Terms(org.elasticsearch.search.aggregations.bucket.terms.Terms) SearchResponse(org.elasticsearch.action.search.SearchResponse) ElasticsearchAssertions.assertSearchResponse(org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse)

Example 17 with IncludeExclude

use of org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude in project elasticsearch by elastic.

the class MaxBucketIT method testNoBuckets.

public void testNoBuckets() throws Exception {
    SearchResponse response = client().prepareSearch("idx").addAggregation(terms("terms").field("tag").includeExclude(new IncludeExclude(null, "tag.*")).subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME))).addAggregation(maxBucket("max_bucket", "terms>sum")).execute().actionGet();
    assertSearchResponse(response);
    Terms terms = response.getAggregations().get("terms");
    assertThat(terms, notNullValue());
    assertThat(terms.getName(), equalTo("terms"));
    List<Terms.Bucket> buckets = terms.getBuckets();
    assertThat(buckets.size(), equalTo(0));
    InternalBucketMetricValue maxBucketValue = response.getAggregations().get("max_bucket");
    assertThat(maxBucketValue, notNullValue());
    assertThat(maxBucketValue.getName(), equalTo("max_bucket"));
    assertThat(maxBucketValue.value(), equalTo(Double.NEGATIVE_INFINITY));
    assertThat(maxBucketValue.keys(), equalTo(new String[0]));
}
Also used : Bucket(org.elasticsearch.search.aggregations.bucket.histogram.Histogram.Bucket) PipelineAggregatorBuilders.maxBucket(org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.maxBucket) IncludeExclude(org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude) Terms(org.elasticsearch.search.aggregations.bucket.terms.Terms) InternalBucketMetricValue(org.elasticsearch.search.aggregations.pipeline.bucketmetrics.InternalBucketMetricValue) SearchResponse(org.elasticsearch.action.search.SearchResponse) ElasticsearchAssertions.assertSearchResponse(org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse)

Example 18 with IncludeExclude

use of org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude in project elasticsearch by elastic.

the class PercentilesBucketIT method testNoBuckets.

public void testNoBuckets() throws Exception {
    SearchResponse response = client().prepareSearch("idx").addAggregation(terms("terms").field("tag").includeExclude(new IncludeExclude(null, "tag.*")).subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME))).addAggregation(percentilesBucket("percentiles_bucket", "terms>sum").percents(PERCENTS)).execute().actionGet();
    assertSearchResponse(response);
    Terms terms = response.getAggregations().get("terms");
    assertThat(terms, notNullValue());
    assertThat(terms.getName(), equalTo("terms"));
    List<Terms.Bucket> buckets = terms.getBuckets();
    assertThat(buckets.size(), equalTo(0));
    PercentilesBucket percentilesBucketValue = response.getAggregations().get("percentiles_bucket");
    assertThat(percentilesBucketValue, notNullValue());
    assertThat(percentilesBucketValue.getName(), equalTo("percentiles_bucket"));
    for (Double p : PERCENTS) {
        assertThat(percentilesBucketValue.percentile(p), equalTo(Double.NaN));
    }
}
Also used : PercentilesBucket(org.elasticsearch.search.aggregations.pipeline.bucketmetrics.percentile.PercentilesBucket) PipelineAggregatorBuilders.percentilesBucket(org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.percentilesBucket) PercentilesBucket(org.elasticsearch.search.aggregations.pipeline.bucketmetrics.percentile.PercentilesBucket) IncludeExclude(org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude) Terms(org.elasticsearch.search.aggregations.bucket.terms.Terms) SearchResponse(org.elasticsearch.action.search.SearchResponse) ElasticsearchAssertions.assertSearchResponse(org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse)

Example 19 with IncludeExclude

use of org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude in project elasticsearch by elastic.

the class StatsBucketIT method testNoBuckets.

public void testNoBuckets() throws Exception {
    SearchResponse response = client().prepareSearch("idx").addAggregation(terms("terms").field("tag").includeExclude(new IncludeExclude(null, "tag.*")).subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME))).addAggregation(statsBucket("stats_bucket", "terms>sum")).execute().actionGet();
    assertSearchResponse(response);
    Terms terms = response.getAggregations().get("terms");
    assertThat(terms, notNullValue());
    assertThat(terms.getName(), equalTo("terms"));
    List<Terms.Bucket> buckets = terms.getBuckets();
    assertThat(buckets.size(), equalTo(0));
    StatsBucket statsBucketValue = response.getAggregations().get("stats_bucket");
    assertThat(statsBucketValue, notNullValue());
    assertThat(statsBucketValue.getName(), equalTo("stats_bucket"));
    assertThat(statsBucketValue.getAvg(), equalTo(Double.NaN));
}
Also used : Bucket(org.elasticsearch.search.aggregations.bucket.histogram.Histogram.Bucket) StatsBucket(org.elasticsearch.search.aggregations.pipeline.bucketmetrics.stats.StatsBucket) PipelineAggregatorBuilders.statsBucket(org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.statsBucket) StatsBucket(org.elasticsearch.search.aggregations.pipeline.bucketmetrics.stats.StatsBucket) IncludeExclude(org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude) Terms(org.elasticsearch.search.aggregations.bucket.terms.Terms) SearchResponse(org.elasticsearch.action.search.SearchResponse) ElasticsearchAssertions.assertSearchResponse(org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse)

Example 20 with IncludeExclude

use of org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude in project elasticsearch by elastic.

the class SumBucketIT method testNoBuckets.

public void testNoBuckets() throws Exception {
    SearchResponse response = client().prepareSearch("idx").addAggregation(terms("terms").field("tag").includeExclude(new IncludeExclude(null, "tag.*")).subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME))).addAggregation(sumBucket("sum_bucket", "terms>sum")).execute().actionGet();
    assertSearchResponse(response);
    Terms terms = response.getAggregations().get("terms");
    assertThat(terms, notNullValue());
    assertThat(terms.getName(), equalTo("terms"));
    List<Terms.Bucket> buckets = terms.getBuckets();
    assertThat(buckets.size(), equalTo(0));
    InternalSimpleValue sumBucketValue = response.getAggregations().get("sum_bucket");
    assertThat(sumBucketValue, notNullValue());
    assertThat(sumBucketValue.getName(), equalTo("sum_bucket"));
    assertThat(sumBucketValue.value(), equalTo(0.0));
}
Also used : Bucket(org.elasticsearch.search.aggregations.bucket.histogram.Histogram.Bucket) PipelineAggregatorBuilders.sumBucket(org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.sumBucket) IncludeExclude(org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude) Terms(org.elasticsearch.search.aggregations.bucket.terms.Terms) SearchResponse(org.elasticsearch.action.search.SearchResponse) ElasticsearchAssertions.assertSearchResponse(org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse)

Aggregations

IncludeExclude (org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude)33 SearchResponse (org.elasticsearch.action.search.SearchResponse)19 ElasticsearchAssertions.assertSearchResponse (org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse)18 Terms (org.elasticsearch.search.aggregations.bucket.terms.Terms)16 Bucket (org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket)7 Bucket (org.elasticsearch.search.aggregations.bucket.histogram.Histogram.Bucket)6 HashSet (java.util.HashSet)5 TreeSet (java.util.TreeSet)4 BytesRef (org.apache.lucene.util.BytesRef)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 RegExp (org.apache.lucene.util.automaton.RegExp)3 TermQueryBuilder (org.elasticsearch.index.query.TermQueryBuilder)3 SignificantTerms (org.elasticsearch.search.aggregations.bucket.significant.SignificantTerms)3 LongBitSet (org.apache.lucene.util.LongBitSet)2 QueryParseContext (org.elasticsearch.index.query.QueryParseContext)2 Script (org.elasticsearch.script.Script)2 DocValueFormat (org.elasticsearch.search.DocValueFormat)2 AggregationExecutionException (org.elasticsearch.search.aggregations.AggregationExecutionException)2 Bucket (org.elasticsearch.search.aggregations.bucket.significant.SignificantTerms.Bucket)2 BucketCountThresholds (org.elasticsearch.search.aggregations.bucket.terms.TermsAggregator.BucketCountThresholds)2