Random random = new Random( 42 );
for ( int i = 0; i < iterations; i++ ) {
Point center = Point.fromDegrees( random.nextDouble() * 2 + 44 , random.nextDouble() * 2 + 3 );
double radius = 25.0d;
Rectangle boundingBox = Rectangle.fromBoundingCircle( center, radius );
query = queryBuilder.bool()
.must(
queryBuilder.range()
.onField( "latitude" )
.from( boundingBox.getLowerLeft().getLatitude() )
.to( boundingBox.getUpperRight().getLatitude() )
.createQuery()
)
.must(
queryBuilder.range()
.onField( "longitude" )
.from( boundingBox.getLowerLeft().getLongitude() )
.to( boundingBox.getUpperRight().getLongitude() )
.createQuery()
)
.createQuery();
hibQuery = fullTextSession.createFullTextQuery( query, POI.class );
hibQuery.setProjection( "id", "name" );
startTime = System.nanoTime();
try {
doubleRangeDocsFetched += hibQuery.getResultSize();
}
finally {
endTime = System.nanoTime();
}
duration = endTime - startTime;
if ( i > warmUp ) {
doubleRangeTotalDuration += duration;
}
session.clear();
query = queryBuilder.bool()
.must(
queryBuilder.range()
.onField( "latitude" )
.from( boundingBox.getLowerLeft().getLatitude() )
.to( boundingBox.getUpperRight().getLatitude() )
.createQuery()
)
.must(
queryBuilder.range()
.onField( "longitude" )
.from( boundingBox.getLowerLeft().getLongitude() )
.to( boundingBox.getUpperRight().getLongitude() )
.createQuery()
)
.createQuery();
org.apache.lucene.search.Query filteredQuery = new ConstantScoreQuery(
SpatialQueryBuilderFromCoordinates.buildDistanceFilter(