Spring Data Rest /search endpoint with MongoDB Geo Types (Circle, Point)

326 Views Asked by At

I try to implement a location based search with Spring Data REST and MongoDB. Firstly I created a model.

public class Event {

    @Id
    private String id;

    private String name;
    private String description;
    private double[] position;

    .. getter setter ..
}

Secondly i added a repository.

public interface EventRepository extends MongoRepository<Event, String> {

    List<Event> findByName(@Param("name") String name);

    List<Event> findByPositionWithin(@Param("circle") Circle c);

    List<Event> findByPositionNear(@Param("point") Point p, @Param("distance") Distance d);

}

However now I encounter the issue that I don't know how to call the /search endpoint for findByPositionWithin and findByPositionNear? I'm not able to find any refs or docs how to pass a complex type to the method.

The findByName endpoint events/search/findByName?name=test works well. How do I pass the circle parameter? Do I need to write a Custom Message Conversion?

Hope someone has any advice :)

0

There are 0 best solutions below