use of org.elasticsearch.search.aggregations.bucket.terms.TermsAggregatorFactory.ExecutionMode in project elasticsearch by elastic.
the class MissingValueIT method testStringTerms.
public void testStringTerms() {
for (ExecutionMode mode : ExecutionMode.values()) {
SearchResponse response = client().prepareSearch("idx").addAggregation(terms("my_terms").field("str").executionHint(mode.toString()).missing("bar")).get();
assertSearchResponse(response);
Terms terms = response.getAggregations().get("my_terms");
assertEquals(2, terms.getBuckets().size());
assertEquals(1, terms.getBucketByKey("foo").getDocCount());
assertEquals(1, terms.getBucketByKey("bar").getDocCount());
response = client().prepareSearch("idx").addAggregation(terms("my_terms").field("str").missing("foo")).get();
assertSearchResponse(response);
terms = response.getAggregations().get("my_terms");
assertEquals(1, terms.getBuckets().size());
assertEquals(2, terms.getBucketByKey("foo").getDocCount());
}
}
use of org.elasticsearch.search.aggregations.bucket.terms.TermsAggregatorFactory.ExecutionMode in project elasticsearch by elastic.
the class StringTermsIT method testSingleValueFieldWithGlobalOrdinals.
public void testSingleValueFieldWithGlobalOrdinals() throws Exception {
ExecutionMode[] executionModes = new ExecutionMode[] { null, ExecutionMode.GLOBAL_ORDINALS, ExecutionMode.GLOBAL_ORDINALS_HASH, ExecutionMode.GLOBAL_ORDINALS_LOW_CARDINALITY };
for (ExecutionMode executionMode : executionModes) {
logger.info("Execution mode: {}", executionMode);
SearchResponse response = client().prepareSearch("idx").setTypes("type").addAggregation(terms("terms").executionHint(executionMode == null ? null : executionMode.toString()).field(SINGLE_VALUED_FIELD_NAME).collectMode(randomFrom(SubAggCollectionMode.values()))).execute().actionGet();
assertSearchResponse(response);
Terms terms = response.getAggregations().get("terms");
assertThat(terms, notNullValue());
assertThat(terms.getName(), equalTo("terms"));
assertThat(terms.getBuckets().size(), equalTo(5));
for (int i = 0; i < 5; i++) {
Terms.Bucket bucket = terms.getBucketByKey("val" + i);
assertThat(bucket, notNullValue());
assertThat(key(bucket), equalTo("val" + i));
assertThat(bucket.getDocCount(), equalTo(1L));
}
}
}
Aggregations