Using Couchbase GeoSpatial and SpringData




I’m trying to implement in my app a geolocation service through Couchbase & SpringData but I’m facing issues that I can’t solve :confused:

Let me explain, I have a repository called PersonRepository :

 public interface PersonRepository extends CrudRepository<Person, String> {

@Dimensional(dimensions=2, designDocument="dev_userSpatial", spatialViewName="byLocation")
	    Set<Person> findByLocationNear(Point location,Distance distance);


Then a PersonService Interface and his implementation :

public interface PersonService {
    Person getPersonById(String id);
    void delete(Person person);
    void create(Person person);
    List<Person> getPersonByFirstName(String firstName);
    List<Person> findByAge(String age);
    List<Person> findAll();
	Set<Person> findByLocationNear(Point location, Distance distance);

public class PersonServiceImpl implements PersonService{
    private PersonRepository personRepository;

public Person getPersonById(String id) {
	return personRepository.findById(id).orElse(new Person());
public void delete(Person person) {
public void create(Person person) {;

public List<Person> getPersonByFirstName(String firstName) {
	return personRepository.findByFirstName(firstName);
public List<Person> findByAge(String age) {
	return null;
public Set<Person> findByLocationNear(Point location,Distance distance) {
	return personRepository.findByLocationNear(location, distance);
public List<Person> findAll() {
	List<Person> persons = new ArrayList<Person>();
	Iterator<Person> it = personRepository.findAll().iterator();
	while(it.hasNext()) {
	return persons;


And now in my Controller I invoke my findByLocationNear method like this :


Then I’ve activated Log with Debug level and I see that request
Executing spatial view query: stale=false&start_range=[4.803032144057112,45.76963214405711]&end_range=[4.8061678559428875,45.77276785594289]

and when I see on the map these start_Range & End_Range coordonates are not separated by 10km but by 430 meters and I’m not getting any documents returned cause i’m not in the good range.

My Spatial view function is configured like this :

 function (doc,meta) {
  if (doc.location &&
      doc._class == "") {
    emit([doc.location.x, doc.location.y], null);

Any idea how to solve this ?

Thank you all :slight_smile: ,