.addUnboundedTo(1)
)
.execute().actionGet();
assertThat(searchResponse.hits().totalHits(), equalTo(7l));
GeoDistanceFacet facet = searchResponse.facets().facet("geo1");
assertThat(facet.entries().size(), equalTo(4));
assertThat(facet.entries().get(0).to(), closeTo(2, 0.000001));
assertThat(facet.entries().get(0).count(), equalTo(4l));
assertThat(facet.entries().get(0).total(), not(closeTo(0, 0.00001)));
assertThat(facet.entries().get(1).from(), closeTo(0, 0.000001));
assertThat(facet.entries().get(1).to(), closeTo(1, 0.000001));
assertThat(facet.entries().get(1).count(), equalTo(2l));
assertThat(facet.entries().get(1).total(), not(closeTo(0, 0.00001)));
assertThat(facet.entries().get(2).from(), closeTo(0.5, 0.000001));
assertThat(facet.entries().get(2).to(), closeTo(2.5, 0.000001));
assertThat(facet.entries().get(2).count(), equalTo(3l));
assertThat(facet.entries().get(2).total(), not(closeTo(0, 0.00001)));
assertThat(facet.entries().get(3).from(), closeTo(1, 0.000001));
assertThat(facet.entries().get(3).count(), equalTo(5l));
assertThat(facet.entries().get(3).total(), not(closeTo(0, 0.00001)));
searchResponse = client.prepareSearch() // from NY
.setQuery(matchAllQuery())
.addFacet(geoDistanceFacet("geo1").field("location").point(40.7143528, -74.0059731).unit(DistanceUnit.KILOMETERS).valueField("num")
.addUnboundedFrom(2)
.addRange(0, 1)
.addRange(0.5, 2.5)
.addUnboundedTo(1)
)
.execute().actionGet();
assertThat(searchResponse.hits().totalHits(), equalTo(7l));
facet = searchResponse.facets().facet("geo1");
assertThat(facet.entries().size(), equalTo(4));
assertThat(facet.entries().get(0).to(), closeTo(2, 0.000001));
assertThat(facet.entries().get(0).count(), equalTo(4l));
assertThat(facet.entries().get(0).total(), closeTo(13, 0.00001));
assertThat(facet.entries().get(1).from(), closeTo(0, 0.000001));
assertThat(facet.entries().get(1).to(), closeTo(1, 0.000001));
assertThat(facet.entries().get(1).count(), equalTo(2l));
assertThat(facet.entries().get(1).total(), closeTo(4, 0.00001));
assertThat(facet.entries().get(2).from(), closeTo(0.5, 0.000001));
assertThat(facet.entries().get(2).to(), closeTo(2.5, 0.000001));
assertThat(facet.entries().get(2).count(), equalTo(3l));
assertThat(facet.entries().get(2).total(), closeTo(15, 0.00001));
assertThat(facet.entries().get(3).from(), closeTo(1, 0.000001));
assertThat(facet.entries().get(3).count(), equalTo(5l));
assertThat(facet.entries().get(3).total(), closeTo(24, 0.00001));
searchResponse = client.prepareSearch() // from NY
.setQuery(matchAllQuery())
.addFacet(geoDistanceFacet("geo1").field("location").point(40.7143528, -74.0059731).unit(DistanceUnit.KILOMETERS).valueScript("doc['num'].value")
.addUnboundedFrom(2)
.addRange(0, 1)
.addRange(0.5, 2.5)
.addUnboundedTo(1)
)
.execute().actionGet();
assertThat(searchResponse.hits().totalHits(), equalTo(7l));
facet = searchResponse.facets().facet("geo1");
assertThat(facet.entries().size(), equalTo(4));
assertThat(facet.entries().get(0).to(), closeTo(2, 0.000001));
assertThat(facet.entries().get(0).count(), equalTo(4l));
assertThat(facet.entries().get(0).total(), closeTo(13, 0.00001));
assertThat(facet.entries().get(1).from(), closeTo(0, 0.000001));
assertThat(facet.entries().get(1).to(), closeTo(1, 0.000001));
assertThat(facet.entries().get(1).count(), equalTo(2l));
assertThat(facet.entries().get(1).total(), closeTo(4, 0.00001));
assertThat(facet.entries().get(2).from(), closeTo(0.5, 0.000001));
assertThat(facet.entries().get(2).to(), closeTo(2.5, 0.000001));
assertThat(facet.entries().get(2).count(), equalTo(3l));
assertThat(facet.entries().get(2).total(), closeTo(15, 0.00001));
assertThat(facet.entries().get(3).from(), closeTo(1, 0.000001));
assertThat(facet.entries().get(3).count(), equalTo(5l));
assertThat(facet.entries().get(3).total(), closeTo(24, 0.00001));
}