I am using Spring Data Redis to save some addresses, each contains a location property of type Point that holds the geo-coordinates of the particular address. Also, the property is annotated with @GeoIndexed. Like what described here: Geospatial Index.
My Address model looks like this:
@RedisHash("addresses")
public class Address {
@Id
private String id;
@GeoIndexed
private Point location;
}
I was able to get all nearby addresses to a given point and distance with this repository query:
public interface AddressRepository extends CrudRepository<Address, String> {
List<Address> findByLocationNear(Point location, Distance distance);
}
My problem is that the returned addresses by the above query are unsorted but I need them to be sorted from the nearest to the furthest (ASC option described here: GEORADIUS - Redis Command).
So, generally, I need a way to pass additional arguments to this query such as sorting or limiting the results (any option of GEORADIUS - Redis Command).
Can anyone help, please?