We're updating the issue view to help you get more done. 

Spatial Search with distance projection is not returning all results

Description

I have created a class with fields annotated with @Latitude and @Longitude:

https://github.com/infinispan/infinispan/blob/master/integrationtests/as-lucene-directory/src/test/java/org/infinispan/test/integration/as/wildfly/model/Member.java

This method is used to perform a spatial search:

1 2 3 4 5 6 7 8 9 public List<Member> spatialSearch(double latitude, double longitude, double distanceinKM) { Query spatialQuery = Search.getFullTextEntityManager(em).getSearchFactory() .buildQueryBuilder().forEntity( Member.class ).get().spatial() .within( distanceinKM, Unit.KM ) .ofLatitude( latitude ) .andLongitude( longitude ) .createQuery(); return Search.getFullTextEntityManager(em).createFullTextQuery(spatialQuery, Member.class).getResultList(); }

This method is used to perform a spatial search and also uses a projection to return the distance each member is from the specified longitude and latitude:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 public List<Object[]> spatialSearchWithDistance(double latitude, double longitude, double distanceinKM) { Query spatialQuery = Search.getFullTextEntityManager(em).getSearchFactory() .buildQueryBuilder().forEntity(Member.class).get().spatial() .onField("location") .within(distanceinKM, Unit.KM) .ofLatitude(latitude) .andLongitude(longitude) .createQuery(); FullTextQuery hibQuery = Search.getFullTextEntityManager(em).createFullTextQuery(spatialQuery, Member.class); hibQuery.setProjection(FullTextQuery.SPATIAL_DISTANCE, FullTextQuery.THIS); hibQuery.setSpatialParameters(latitude, longitude, "location"); return hibQuery.getResultList(); }

Then created objects that have the latitude and longitude set. When I search using a search radius that should include multiple members, the first method returns both members. However when using the same parameters, the second method only returns one member.

Environment

None

Status

Assignee

Nicolas Helleringer

Reporter

Alan Field

Labels

None

Suitable for new contributors

None

Feedback Requested

None

Components

Fix versions

Affects versions

5.3.0.Final

Priority

Major