Neo4j Spatial which tool to use with Neo4j Server

I'm currently exploring Spatial support for Neo4j. Until now I've been using PostGIS for storing and querying Openstreetmap Data, but I want to use Neo4j for this approach. When using Neo4j I first discovered the very old neo4j-spatial-plugin. Using this plugin I was able to import first .osm-Files using the commandline, but only for Neo4j 4.1.6. Later I saw the Neo4j/osm github and used this Importer for a second Database, again only with the commandline. Both plugins where only compatible for Neo4j 4.1.6 or older Versions, which didn't satisfy me.
Next I discovered a third plugin Neo4j/spatial, which seems to provide an Importer with support for newer Versions and even had spatial functions included. But this plugin seems to be different than the other two. Since I use Neo4j as a Server and not as an embedded system, I couldnt figure out if it is possible to use this plugin. The other two plugins provided functions with the Commandline to import OSM Files. (procedures where very slow in importing so I had so cancel it)

So my question is, which of these programs should I use when using neo4j as a server? And apart from procedures, are these plugins usable with the Neo4j server? Using them in a Java Application would be cool.

LG Gregor.

Please create spatial indexing at appropriate Nodes so that the timings can be improved.
Many thanks
Mr Sameer Sudhir G

First plugin: Neo4j Spatial
Second Plugin: Neo4j OSM

The first plugin has an OSMImporter with Support for newer Neo4j versions, but as far as I know only for Neo4j Embedded (?).

OSMImporter importer = new OSMImporter("sweden");
    Map<String, String> config = new HashMap<String, String>();
    config.put("neostore.nodestore.db.mapped_memory", "90M" );
    config.put("dump_configuration", "true");
    config.put("use_memory_mapped_buffers", "true");
    BatchInserter batchInserter = BatchInserters.inserter(new File(dir), config);
    importer.importFile(batchInserter, "sweden.osm", false);
    batchInserter.shutdown();

    GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabase(dir);
    importer.reIndex(db, 10000);
    db.shutdown();

The second Plugin has an OSMImporter for Neo4j-4.1.6 and supports Neo4j-Embedded and Neo4j-Server via commandline.

java -Xms1280m -Xmx1280m \
  -cp "target/osm-0.2.3-neo4j-4.1.6.jar:target/dependency/*" org.neo4j.gis.osm.OSMImportTool \
  --skip-duplicate-nodes --delete --into target/neo4j --database map2 samples/map2.osm.bz2

So is there a way to Import OSM-Files into an Neo4j Server (not embedded) newer than Version 4.1.6 ?

Thanks for the Response. I thought the Spatial-Index is created during the Import with the Neo4j-OSM-Plugin

After a some tests and research this is what I came up with:

Neo4j-OSM is a Importer and Model for OSM Data optimised for routing. There is no spatial index included, the spatial index of Neo4j for Points can be used. Here an offline Importer, via commandline, enables fast Imports for Neo4j-Server (See Java command above).

Neo4j-Spatial is an Importer an Model with an RTREE Spatial Index, like Postgis. Spatial functions like Within, Intersect or Contains can be executed. The Modell is a different one to Neo4j-OSM and not suitable for routing. For importing there are two ways:

  1. Import via Java Application but only for embedded use (?)

OSMImporter importer = new OSMImporter("sweden");
    Map<String, String> config = new HashMap<String, String>();
    config.put("neostore.nodestore.db.mapped_memory", "90M" );
    config.put("dump_configuration", "true");
    config.put("use_memory_mapped_buffers", "true");
    BatchInserter batchInserter = BatchInserters.inserter(new File(dir), config);
    importer.importFile(batchInserter, "sweden.osm", false);
    batchInserter.shutdown();

    GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabase(dir);
    importer.reIndex(db, 10000);
    db.shutdown();

GraphDatabaseService does not exists in the Java Driver for Neo4j-Server. Is there a Way to make this Java code work with the Neo4j-Server Java driver ?

  1. Import with procedure:
CALL spatial.importOSM(osmfile);

This worked for a small file in Neo4j-4.1.6 and I think newer Versions will work to. This enabled the Import to an Neo4j-Server, but it’s really slow (which was mentioned by @craig.taverner in this post.

How can I Import larger files with the Neo4j-Spatial Model ?

Th Neo4j-OSM README says

  • Can replace the older OSMImporter in Neo4j Spatial (ie. should work with Neo4j Spatial also).

But the two Models are completely different, for an example:

Neo4j-OSM:

  1. no layers
  2. only spatial index for point geometries
  3. Relations have „member“-relations to assign members

Neo4j-Spatial:

  1. RTREE spatial index
  2. layers with more komplex geometries than Points
  3. relations only have tags and name (?)

The only similarity I see is the structure of ways and nodes.

So how are these two Importers compatible? Can I create a OSMLayer in the Neo4j-OSM Model ? Or can I use the routeIntersection from Neo4j-OSM in the Neo4j-Spatial Model ?

Many questions, sorry but I’m really confused by this statement