How do I export a remote graph to json using tinkerpop gremlin and neptune?

Viewed 2255

I'm trying to export an entire remote graph into json. When I use the following code, it results in an empty file. I am using Gremlin-driver 3.3.2 as this is the same version in the underling graph database, AWS Neptune.

var traversal = EmptyGraph.instance().traversal().withRemote(DriverRemoteConnection.using(getCluster()))
traversal.getGraph().io(graphson()).writeGraph("my-graph.json");

How is one supposed to populate the graph with data such that it can be exported?

4 Answers

I also posted this to the Gremlin Users list.

Here's some code that will do it for you with Neptune and should work with most Gremlin Server implementations I would think.

https://github.com/awslabs/amazon-neptune-tools/tree/master/neptune-export

The results of the export can be used to load via Neptune's bulk loader if you choose to export as CSV.

Hope that is useful

If that is more than you needed hopefully it will at least give you some pointers that help.

With hosted graphs, including Neptune, it is not uncommon to find that they do not expose the Graph object or give access to the io() classes.

The Gremlin io( ) Step is not supported in Neptune. Here is the Neptune's documentation which talks about the other difference between the Amazon Neptune implementation of Gremlin and the TinkerPop implementation.

Taking on-board the valuable feed-back from Ankit and Kelvin, I concentrated on using a local gremlin server to handle the data wrangling.

Once I had the data in a locally running server, by generating gremlin script from an in-memory entity model,I accessed it via a Gremlin console and ran the following:

~/apache-tinkerpop-gremlin-console-3.3.7/bin/gremlin.sh
gremlin> :remote connect tinkerpop.server conf/remote.yaml
gremlin> :> graph.io(graphson()).writeGraph("my-graph.json")
==>null

This put the my-graph.json file in /opt/gremlin-server/ on the docker container. I extracted it using docker cp $(docker container ls -q):/opt/gremlin-server/my-graph.json .

I can then use this data to populate a gremlin-server testcontainer for running integration tests against a graph database.

neptune-export doesn't support direct export to S3. You'll have to export to the local file system, and then separately copy the files to S3.

Related