use of org.elasticsearch.search.aggregations.metrics.geobounds.GeoBounds in project elasticsearch by elastic.
the class GeoBoundsIT method testSingleValuedFieldAsSubAggToHighCardTermsAgg.
/**
* This test forces the {@link GeoBoundsAggregator} to resize the {@link BigArray}s it uses to ensure they are resized correctly
*/
public void testSingleValuedFieldAsSubAggToHighCardTermsAgg() {
SearchResponse response = client().prepareSearch(HIGH_CARD_IDX_NAME).addAggregation(terms("terms").field(NUMBER_FIELD_NAME).subAggregation(geoBounds(aggName).field(SINGLE_VALUED_FIELD_NAME).wrapLongitude(false))).execute().actionGet();
assertSearchResponse(response);
Terms terms = response.getAggregations().get("terms");
assertThat(terms, notNullValue());
assertThat(terms.getName(), equalTo("terms"));
List<Bucket> buckets = terms.getBuckets();
assertThat(buckets.size(), equalTo(10));
for (int i = 0; i < 10; i++) {
Bucket bucket = buckets.get(i);
assertThat(bucket, notNullValue());
assertThat("InternalBucket " + bucket.getKey() + " has wrong number of documents", bucket.getDocCount(), equalTo(1L));
GeoBounds geoBounds = bucket.getAggregations().get(aggName);
assertThat(geoBounds, notNullValue());
assertThat(geoBounds.getName(), equalTo(aggName));
assertThat(geoBounds.topLeft().getLat(), allOf(greaterThanOrEqualTo(-90.0), lessThanOrEqualTo(90.0)));
assertThat(geoBounds.topLeft().getLon(), allOf(greaterThanOrEqualTo(-180.0), lessThanOrEqualTo(180.0)));
assertThat(geoBounds.bottomRight().getLat(), allOf(greaterThanOrEqualTo(-90.0), lessThanOrEqualTo(90.0)));
assertThat(geoBounds.bottomRight().getLon(), allOf(greaterThanOrEqualTo(-180.0), lessThanOrEqualTo(180.0)));
}
}
use of org.elasticsearch.search.aggregations.metrics.geobounds.GeoBounds in project elasticsearch by elastic.
the class MissingValueIT method testUnmappedGeoBounds.
public void testUnmappedGeoBounds() {
SearchResponse response = client().prepareSearch("idx").addAggregation(geoBounds("bounds").field("non_existing_field").missing("2,1")).get();
assertSearchResponse(response);
GeoBounds bounds = response.getAggregations().get("bounds");
assertThat(bounds.bottomRight().lat(), closeTo(2.0, 1E-5));
assertThat(bounds.bottomRight().lon(), closeTo(1.0, 1E-5));
assertThat(bounds.topLeft().lat(), closeTo(2.0, 1E-5));
assertThat(bounds.topLeft().lon(), closeTo(1.0, 1E-5));
}
Aggregations