[英]Search and copying nodes from one graph to another in neo4j
Suppose you have 3 graphs with where some data is shared among the graphs. 假设您有3个图,在这些图之间共享一些数据。 Is there then a way programatically to do the following:
那么有没有一种方法可以通过编程来执行以下操作:
In graph 1 find a node 在图1中找到一个节点
Search in graph 2 for that node (through property name) 在图2中搜索该节点(通过属性名称)
If step 2 finds a match, then I would like to take all the nodes connected to the found node in graph 2 (including "nodes indirectly connected") and connect them to the node in graph 1. 如果步骤2找到匹配项,那么我想将所有连接到图2中找到的节点的节点(包括“间接连接的节点”)连接到图1中的节点。
Essentially I would like to search for a particular node in a graph, find all the nodes directly or indirectly connected to and copy the entire connection to my original node in graph 1. 本质上,我想搜索图中的特定节点,找到直接或间接连接的所有节点,并将整个连接复制到图1中的原始节点。
Any hints on how to do this would be great. 关于如何执行此操作的任何提示都将很棒。 Thanks in advance.
提前致谢。
Using Neo4j 1.9 and not too familar with Cypher queries and it is the community edition. 使用Neo4j 1.9并不太熟悉Cypher查询,它是社区版本。
If you have all your 3 graphs in a single database it is simple. 如果您在一个数据库中拥有所有3个图,这很简单。
do the query to find your node 查询以找到您的节点
START a=node.... MATCH ... WHERE ... RETURN a.prop as prop, ID(a) as id
assuming your nodes are indexed for the properties that are interesting for you, do an index lookup for that property 假设为您的节点索引了您感兴趣的属性,请对该属性进行索引查找
START a=node({id}), b=node:index(property={prop})
MATCH (b)-->(c)
CREATE (c)-[:REL_TYPE]->(a)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.