Hi guys, I am new to Neo4j. I want to find out what is the best way to group your nodes so that you can make faster queries based on location using Neo4j.
I will have a lot of users in the database. I will be making queries to return the top 10 users closest to a particular user/location. When making the query, I want to narrow down the search before working out the distances between the users and then ranking them based on who is the closest.
I need advice on the best approach using Neo4j. I can think of two ways to group them but I am not sure if it's feasible or how to execute them yet.
1) Divide the world up into grids, give each grid a cell id and create a node for each id. Make a direct relationship between the users and the cell id.
2) Create a node for each city or town. All users living in that town or city will have a direct relationship. But if I do that how should I group a user that shares two borders?
Please see image
This is what I understood from your image.
1.Waterloo: from lat and lang values this address is in Canada. User 1 and User 2 lat and lang values show the addresses in London, UK. I assume these Users have two addresses in two different countries. This what you are referring in option 2.
2. I prefer option 2 and add PrimaryResidence and SecondaryResidence properties to each user. For users with no SecondaryResidence you can set 'NA' and thus avoid null values issues.
Hope my analysis is correct.
I do not know anything about your grid and its properties. How is it connected to many users with different locations?
With option 2: Create a node for each city or town. All users living in that town or city will have a direct relationship.
Q: But if I do that how should I group a user that shares two borders?
A: By creating Primary and Secondary address properties.