Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-27-2022 07:06 AM
Dear Community,
I am facing an interesting problem: I have a graph. A subgraph of it is copied over into a different DB (e.g. subdatabase in Neo4j) and being worked on. Now if the user wants to save his changes, these changes need to be transfered back into the original graph. Basically, I am looking for a "git commit" & "git merge" functionality, where a user "creates a local branch", "commits his changes" and the changes are then "merged" into the "main branch". Is there something like that? Has anyone had this problem before?
I know that there are certain methods to compare two graphs to see whether there are differences (e.g. producing an md5sum) but is there a simple way to "apply" the differences to the other graph?
Looking forward to a good discussion,
Elena
04-27-2022 04:27 PM
How big of a subgraph are you talking about? I have an idea based on something I am using to host demo "fake" data that I think might be applicable.
04-28-2022 12:13 AM
Not too big. My "main" graph consists of about 5000 nodes and the subgraph of about 1500. The actual changes that I want to "commit and merge" apply to a subsubgraph of about 100-200 nodes with about 100 relationships maybe.
05-01-2022 06:12 PM
Ok, so this might not be the cleanest solution, but it is something I have been using at work.
Use apoc.export.json.query
to export your subquery to a JSON file. Reference the Neo4j Documentation on formatting options. With your subquery as a JSON file you can then commit it to your git repo for your records.
I would say from there you could just edit that JSON file so you can see the changes in the git repo. Or you can load that subgraph into a separate graph and make your changes using Cypher. You can pick your poison. Loading the subgraph into a separate graph to make changes means all of your internal IDs will change, which can make things tricky when you export and migrate the changes back.
Here are some caveats to think about:
Do you think this subgraph changes will be a consistent pattern that you will use to make graph changes?
05-04-2022 12:20 AM
In my view, the tricky part really is the "reimport", so the first caveat you mention. It would be nice to not having to do this "manually". We are also looking for a coded process flow here that executes the merging of the graphs on the click of a button.
As for your second caveat: we are using (additional) ids of our own to identify the nodes and relationships which is why this probably would not be a problem for us.
The changes to the subgraph will be more or less consistent as in there will be a UI where the user can make changes to the displayed entities (nodes / relationships) but is not able to see more than we show him. Hence, there is a big but limited amount of changes possible.
All the sessions of the conference are now available online