Here is the Spring Repository class
public interface UserRepository extends MongoRepository {
@Query(value = "{location :{ $nearSphere :{$geometry : {type : \"Point\", coordinates : [?1, ?0] }, $maxDistance :?2}}")
List<User> search(float latitude, float longitude, float radius, int limit);
}
I'm not able to use limit() function to limit total number of results returned by the search function. I've tried appending limit() in all places within @Query annotation.