2

Note: This is similar to the question asked here: Storing multiple graphs in Neo4J - but this question was asked in 2011 and I haven't found a direct answer for Neo4j 3.

Is there a way to configure the properties for Neo4j so that there are multiple graphs available to my application, using a single Neo4j instance?

My use case is that I would like to operate on multiple similar but discrete graphs. The graph I choose to operate on would be decided on the fly and dynamically during the execution of my application. If I try to choose a graph that doesn't exist yet, it should be created. At points in the future, I may decide to delete one of the graphs, and the deletion would happen independently of the other graphs.

A follow up question is: in the linked post from 2011, an answer mentioned using subgraphs. Is a subgraph set up through neo4j properties, and do they contain each their own set of indexes and property elements?

havenwang
  • 153
  • 9

1 Answers1

1

Assuming your graphs are not sharing nodes. You may try to have a specific label for each graph,like g1, g2 .... and add that label to each node.

Jerome_B
  • 1,079
  • 8
  • 15
  • Just to make sure I get it right: the answer is more like no. One neo4j instance is for serving one graph database, though technically you can have two or more set of nodes that are not attached so can be treated as separate graphs. Is that correct? – Laszlo T May 14 '18 at 13:24
  • 1
    the answer is more like 'it depends'. Neo4j uses one graph at a time. you can store several graphs on same machine (only one is online at a time). One graph can store several unleated grapes of nodes.
    you can have two or more set of nodes that are not attached so can be treated as separate graphs. Is that correct? <--- yes
    – Jerome_B May 14 '18 at 14:20
  • Thanks for the response. I also understand that Neo4j maintains transactional database statistics, so that we can quickly get values like the number of nodes in the graph, the number of relationships, and etc. By creating subgraphs in this manner where they're separated by a specific label (or maybe a prefix on the vertex id), we'd lose the ability to get these statistics, right? Or is there a way around this? – havenwang May 14 '18 at 23:49
  • There is global statitics for # of nodes, yes. And labels too. – Jerome_B May 16 '18 at 01:00
  • Match (n:label1:graph1) return count(n) Will work. You may still want to restart neo with a different neo.conf file for really séparating the nodes. Depending of how many peeps connect at one time and provided they all want to use same data graph Most chances for it to work is with only one user – Jerome_B May 16 '18 at 01:01
  • Neo is a real cool tool, learn more with «learning neo4j, second edition» at packt publishing, that I authored. – Jerome_B May 16 '18 at 01:03