Question

I have my Neo4J (embedded) database setup like this:

  • I attach several user nodes to the reference node.
  • To each user node can be attached one or more project nodes.
  • To each project node is a complex graph attached.

The complex graph is traversable with a single traverse pattern (there is a hidden tree structure in them).

What I'd like to do is the following:

  • Remove all the nodes below a project node.
  • Remove all the project nodes below a user, when there's nothing below the project nodes
  • Export all nodes below a specific user node to .graphML (probably using Gremlin Java API?)
  • Import a .graphML file back to the database below a specific user node without removing the information that is located under different user nodes.

I've already worked with the Gremlin GraphML reader for importing and exporting entire Neo4J databases but I was not able to find something about importing/exporting subgraphs.

If this is in fact possible, how would Neo4J handle two users trying to import something at the same time? For instance user 1 imports his section under the user1 node, and user 2 imports his data under the user 2 node simultaneously.

The other possibility is to have a Neo4J database per user, but this is the less preferable option really and I'm very unsure whether it's actually posssible, be it embedded or server version. I've read something about having multiple server versions on different ports but our amount of users is per definition unlimited...

Any help would be greatly appreciated.

EDIT 1: I've also come across something called Geoff (org.neo4j.geoff) which deals with subgraphs. I'm absolutely clueless as to how this works but I'm looking into it right now.

Was it helpful?

Solution 2

One option may be to use something like Tinkerpop blueprints to create a generic Graph when traversing, then doing a GraphML export.

https://github.com/tinkerpop/blueprints/wiki/GraphML-Reader-and-Writer-Library would have more information, but if you are looking to export subgraphs, this is probably your best option.

OTHER TIPS

You might take a lock on the user node when starting the import, so that the second import would have to wait (and would have to check).

With cypher queries you can delete the subgraphs and also export them to cypher again. There is export code for query-results in the Neo4j Console repository.

There you can also find geoff-export and import and also cypher importers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top