use of org.elasticsearch.search.aggregations.metrics.geobounds.GeoBounds in project elasticsearch by elastic.
the class MissingValueIT method testGeoBounds.
public void testGeoBounds() {
SearchResponse response = client().prepareSearch("idx").addAggregation(geoBounds("bounds").field("location").missing("2,1")).get();
assertSearchResponse(response);
GeoBounds bounds = response.getAggregations().get("bounds");
assertThat(bounds.bottomRight().lat(), closeTo(1.0, 1E-5));
assertThat(bounds.bottomRight().lon(), closeTo(2.0, 1E-5));
assertThat(bounds.topLeft().lat(), closeTo(2.0, 1E-5));
assertThat(bounds.topLeft().lon(), closeTo(1.0, 1E-5));
}
use of org.elasticsearch.search.aggregations.metrics.geobounds.GeoBounds in project elasticsearch by elastic.
the class GeoBoundsIT method testEmptyAggregation.
public void testEmptyAggregation() throws Exception {
SearchResponse searchResponse = client().prepareSearch(EMPTY_IDX_NAME).setQuery(matchAllQuery()).addAggregation(geoBounds(aggName).field(SINGLE_VALUED_FIELD_NAME).wrapLongitude(false)).execute().actionGet();
assertThat(searchResponse.getHits().getTotalHits(), equalTo(0L));
GeoBounds geoBounds = searchResponse.getAggregations().get(aggName);
assertThat(geoBounds, notNullValue());
assertThat(geoBounds.getName(), equalTo(aggName));
GeoPoint topLeft = geoBounds.topLeft();
GeoPoint bottomRight = geoBounds.bottomRight();
assertThat(topLeft, equalTo(null));
assertThat(bottomRight, equalTo(null));
}
use of org.elasticsearch.search.aggregations.metrics.geobounds.GeoBounds in project elasticsearch by elastic.
the class GeoBoundsIT method testSingleValuedFieldNearDateLineWrapLongitude.
public void testSingleValuedFieldNearDateLineWrapLongitude() throws Exception {
GeoPoint geoValuesTopLeft = new GeoPoint(38, 170);
GeoPoint geoValuesBottomRight = new GeoPoint(-24, -175);
SearchResponse response = client().prepareSearch(DATELINE_IDX_NAME).addAggregation(geoBounds(aggName).field(SINGLE_VALUED_FIELD_NAME).wrapLongitude(true)).execute().actionGet();
assertSearchResponse(response);
GeoBounds geoBounds = response.getAggregations().get(aggName);
assertThat(geoBounds, notNullValue());
assertThat(geoBounds.getName(), equalTo(aggName));
GeoPoint topLeft = geoBounds.topLeft();
GeoPoint bottomRight = geoBounds.bottomRight();
assertThat(topLeft.lat(), closeTo(geoValuesTopLeft.lat(), GEOHASH_TOLERANCE));
assertThat(topLeft.lon(), closeTo(geoValuesTopLeft.lon(), GEOHASH_TOLERANCE));
assertThat(bottomRight.lat(), closeTo(geoValuesBottomRight.lat(), GEOHASH_TOLERANCE));
assertThat(bottomRight.lon(), closeTo(geoValuesBottomRight.lon(), GEOHASH_TOLERANCE));
}
use of org.elasticsearch.search.aggregations.metrics.geobounds.GeoBounds in project elasticsearch by elastic.
the class GeoBoundsIT method testSingleValuedFieldWithZeroLon.
public void testSingleValuedFieldWithZeroLon() throws Exception {
SearchResponse response = client().prepareSearch(IDX_ZERO_NAME).addAggregation(geoBounds(aggName).field(SINGLE_VALUED_FIELD_NAME).wrapLongitude(false)).execute().actionGet();
assertSearchResponse(response);
GeoBounds geoBounds = response.getAggregations().get(aggName);
assertThat(geoBounds, notNullValue());
assertThat(geoBounds.getName(), equalTo(aggName));
GeoPoint topLeft = geoBounds.topLeft();
GeoPoint bottomRight = geoBounds.bottomRight();
assertThat(topLeft.lat(), closeTo(1.0, GEOHASH_TOLERANCE));
assertThat(topLeft.lon(), closeTo(0.0, GEOHASH_TOLERANCE));
assertThat(bottomRight.lat(), closeTo(1.0, GEOHASH_TOLERANCE));
assertThat(bottomRight.lon(), closeTo(0.0, GEOHASH_TOLERANCE));
}
use of org.elasticsearch.search.aggregations.metrics.geobounds.GeoBounds in project elasticsearch by elastic.
the class GeoBoundsIT method testSingleValuedFieldNearDateLine.
public void testSingleValuedFieldNearDateLine() throws Exception {
SearchResponse response = client().prepareSearch(DATELINE_IDX_NAME).addAggregation(geoBounds(aggName).field(SINGLE_VALUED_FIELD_NAME).wrapLongitude(false)).execute().actionGet();
assertSearchResponse(response);
GeoPoint geoValuesTopLeft = new GeoPoint(38, -179);
GeoPoint geoValuesBottomRight = new GeoPoint(-24, 178);
GeoBounds geoBounds = response.getAggregations().get(aggName);
assertThat(geoBounds, notNullValue());
assertThat(geoBounds.getName(), equalTo(aggName));
GeoPoint topLeft = geoBounds.topLeft();
GeoPoint bottomRight = geoBounds.bottomRight();
assertThat(topLeft.lat(), closeTo(geoValuesTopLeft.lat(), GEOHASH_TOLERANCE));
assertThat(topLeft.lon(), closeTo(geoValuesTopLeft.lon(), GEOHASH_TOLERANCE));
assertThat(bottomRight.lat(), closeTo(geoValuesBottomRight.lat(), GEOHASH_TOLERANCE));
assertThat(bottomRight.lon(), closeTo(geoValuesBottomRight.lon(), GEOHASH_TOLERANCE));
}
Aggregations