O'Reilly logo

Learning Neo4j 3.x - Second Edition by Rik Van Bruggen, Jérôme Baton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Neo4j's spatial features 

Neo4j has a limited built-in spatial support since Neo4j 3.0. There is default support for point and distance. This support assumes that you will set property keys named latitude and longitude for the nodes you want to use as points.

You can use them to calculate the distance between two nodes, but first let's build the towers, starting with the good habit of creating a constraint:

CREATE CONSTRAINT ON (t:Tower) ASSERT t.name IS UNIQUECREATE (paris:Tower {name: "Eiffel Tower",country:"FRA", latitude:48.858093, longitude:2.294694})CREATE (vegas:Tower {name: "Vegas Eiffel Tower",country:"USA", latitude:36.112474, longitude:-115.172737})CREATE (tokyo:Tower {name: "Tokyo Tower",country:"JPN", latitude:35.659053,longitude:139.745228}) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required