Skip to content

Commit

Permalink
HSEARCH-2434 Fix spatial tests on ES 5
Browse files Browse the repository at this point in the history
The bounding box query doesn't include geo points located on the left
and bottom sides of the box as of ES 5.
  • Loading branch information
yrodiere committed Mar 21, 2017
1 parent 58c7ada commit 66bd1c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void testBoundingBoxQuery() {
"'location' : {\n" +
"'top_left' : {\n" +
"'lat' : 24,\n" +
"'lon' : 31.9\n" +
"'lon' : 31.8\n" +
"},\n" +
"'bottom_right' : {\n" +
"'lat' : 23.8,\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
*/
public class SpatialQueryingJPATest extends JPATestCase {

// Use a large, but reasonable distance: Elasticsearch 5 can't handle Double.MAX_VALUE for instance
private static final double LARGE_DISTANCE_KM = 40_000;

@After
public void cleanup() {
withinEntityManager( factory, em -> {
Expand Down Expand Up @@ -118,7 +121,7 @@ public void testDistanceProjectionWithoutSortMissingCoordinates() throws Excepti
final QueryBuilder builder = em.getSearchFactory().buildQueryBuilder().forEntity( POI.class ).get();

org.apache.lucene.search.Query luceneQuery = builder.spatial().onField( "location" )
.within( Double.MAX_VALUE, Unit.KM ).ofLatitude( centerLatitude ).andLongitude( centerLongitude ).createQuery();
.within( LARGE_DISTANCE_KM, Unit.KM ).ofLatitude( centerLatitude ).andLongitude( centerLongitude ).createQuery();

FullTextQuery hibQuery = em.createFullTextQuery( luceneQuery, POI.class );
hibQuery.setProjection( FullTextQuery.THIS, FullTextQuery.SPATIAL_DISTANCE );
Expand Down

0 comments on commit 66bd1c4

Please sign in to comment.