Importing data from the Geoff format to Neo4j
Graph data comes in different formats, and sometimes it's a combination of two or more formats. It is very important to learn about the various ways to import data having different formats into Neo4j. In this recipe, you will learn how to import data that is present in the Geoff format, into the Neo4j graph database server.
Getting ready
To get started with this recipe, install Neo4j by using the steps from the earlier recipes of this chapter.
How to do it...
The data in the Geoff format can be easily imported using the load2neo tool available at http://nigelsmall.com/load2neo.
The following is the code for building the tool:
wget http://nigelsmall.com/d/load2neo-0.6.0.zip
This ZIP archive contains three files: two JAR files which that need to be copied to your Neo4j plugin directory and a neo4j-server.properties
file that contains has content to be added to the identically named file within the Neo4j conf
directory. This is a single line that mounts the plugin at the correct URI offset.
How it works...
Geoff is a text-based interchange format for Neo4j graph data that should be instantly readable to anyone familiar with Cypher, on which its syntax is based.
This is the syntax of Geoff:
(alice {"name":"Alice"}) (bob {"name":"Bob"}) (carol {"name":"Carol"}) (alice)<-[:KNOWS]->(bob)<-[:KNOWS]->(carol)<-[:KNOWS]->(alice)
Bulk load
Bulk loads can be executed by running the following curl
command from the command line:
curl -X POST http://localhost:7474/load2neo/load/geoff -d '(a)<-[:KNOWS]->(b)'
See also
To know more about the Geoff format, go to http://nigelsmall.com/geoff.