cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Get 15 of the closest people on Neo4J using spatial functions

Let's say I have 20 people each with a point with a latitude and longitude associated with it. How would I write a query to return the 15 closest people to a particular person.

Thanks for all your help!

1 REPLY 1

How about:

MATCH (person:Person) WHERE person.name = 'Important Person'
MATCH (other:Person) WHERE distance(person.location, other.location) < 10000
RETURN other.name, distance(person.location, other.location) AS distance
ORDER BY distance DESC
LIMIT 15