Neo4J从查询结果创建新数据库
Neo4J有没有办法创建一个新的数据库,该数据库被另一个数据库中的某些查询数据填充了吗?
可以通过以下语句创建上面的图表: (在此示例中,想象图是完整的数据库)
CREATE (n0:Node)
CREATE (n1:Node)
CREATE (n2:Node {capital_letter: "A"})
CREATE (n3:Node)
CREATE (n4:Node)
CREATE (n5:Node)
CREATE (n6:Node {capital_letter: "B"})
CREATE (n7:Node)
CREATE (n8:Node {capital_letter: "A"})
CREATE (n9:Node {capital_letter: "B"})
CREATE (n10:Node)
CREATE (n2)-[:TRANSACTIONS]->(n0)
CREATE (n2)-[:TRANSACTIONS]->(n1)
CREATE (n2)-[:TRANSACTIONS]->(n3)
CREATE (n3)-[:TRANSACTIONS]->(n6)
CREATE (n4)-[:TRANSACTIONS]->(n2)
CREATE (n4)-[:TRANSACTIONS]->(n7)
CREATE (n6)-[:TRANSACTIONS]->(n5)
我的问题:
是否有任何方法可以查询这些节点的子图片,然后将它们放入一个新的持久数据库中?
我想像以下内容:
INSERT INTO NEW DATABASE "NEW DB"
MATCH (a {capital_letter: "A"})
OPTIONAL MATCH (a {capital_letter: "A"})-[t1]-(a_neighbours)
MATCH (b {capital_letter: "B"})
OPTIONAL MATCH (b {capital_letter: "B"})-[t2]-(b_neighbours)
RETURN a, b, t1, t2, a_neighbours, b_neighbours
当然上述语句不起作用,但是 neo4j是否有可能构造这样的数据库?
请注意,我的数据库由100mio+节点组成,因此只有一种可行的方法确实很有帮助。
**我的最后一个手段是只查询数据,将其导出到.csv,然后通过neo4j-admin工具构建一个新数据库 https://neo4j.com/docs/operations-manual/manual/current/current/current/tutorial/neo4j-admin-import/
我只想知道如果有另一种(也许更快)的方式。
Is there a way in Neo4j to create a new Database, that gets populated by some query data from another database?
For Example, I have a Database that consists of the following Nodes:
The Graph from above can be created via the following statement:
(In this example imagine the graph is the full database)
CREATE (n0:Node)
CREATE (n1:Node)
CREATE (n2:Node {capital_letter: "A"})
CREATE (n3:Node)
CREATE (n4:Node)
CREATE (n5:Node)
CREATE (n6:Node {capital_letter: "B"})
CREATE (n7:Node)
CREATE (n8:Node {capital_letter: "A"})
CREATE (n9:Node {capital_letter: "B"})
CREATE (n10:Node)
CREATE (n2)-[:TRANSACTIONS]->(n0)
CREATE (n2)-[:TRANSACTIONS]->(n1)
CREATE (n2)-[:TRANSACTIONS]->(n3)
CREATE (n3)-[:TRANSACTIONS]->(n6)
CREATE (n4)-[:TRANSACTIONS]->(n2)
CREATE (n4)-[:TRANSACTIONS]->(n7)
CREATE (n6)-[:TRANSACTIONS]->(n5)
MY QUESTION:
Is there is any way to query for a sub-graph of these nodes, to then put them into a new persistent database?
For example I would like to build a new Database, with all A and B nodes, aswell as all their neighbours and all the relationships between them.
I imagine something like the following:
INSERT INTO NEW DATABASE "NEW DB"
MATCH (a {capital_letter: "A"})
OPTIONAL MATCH (a {capital_letter: "A"})-[t1]-(a_neighbours)
MATCH (b {capital_letter: "B"})
OPTIONAL MATCH (b {capital_letter: "B"})-[t2]-(b_neighbours)
RETURN a, b, t1, t2, a_neighbours, b_neighbours
Of course the above statement does not work, but is there any possibility in Neo4J to construct a Database like so?
Please note, that my Database consists of 100Mio+ Nodes so only a feasable approach is really helpful.
**My last resort would be to just query the data, export it to .csv and then construct a new database via the neo4j-admin tool https://neo4j.com/docs/operations-manual/current/tutorial/neo4j-admin-import/
I just want to know if there is another (maybe quicker) way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在NEO4J世界中,DML和DDL语句并非彼此隔离。通过转储文件或CSV导出源数据并导入它是唯一的本机选项。
如果您要连接到neo4j 通过另一种编程语言源图并将结果写入目标图。
In the Neo4j world, DML and DDL statements are not isolated from each other. Exporting the source data either through a dump file or CSV and importing it is the only native option.
If you are connecting to Neo4j through another Programming Language, you could build logic there to read from the source Graph and write the results to the destination Graph.