简体   繁体   English

在neo4j中将节点从一个图搜索并复制到另一个图

[英]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: 那么有没有一种方法可以通过编程来执行以下操作:

  1. In graph 1 find a node 在图1中找到一个节点

  2. Search in graph 2 for that node (through property name) 在图2中搜索该节点(通过属性名称)

  3. 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.

相关问题 如何将Neo4j节点从一个数据库传递到另一个数据库 - How to pass neo4j Nodes from one database to another 在Neo4J Java中,如何搜索处于一种关系而不是另一种关系的endNodes - How to search for endNodes, that are in one relationship, but not another in Neo4J Java neo4j图形数据库中是否可能具有不同类型的节点 - Is it possible to have different types of nodes in a neo4j graph database 使用 java 从 neo4j 获取所有图形数据,包括节点和关系到 hashmap - get all graph data including nodes and relationships from neo4j using java into a hashmap 如何查看从Neo4J Java应用程序创建的节点的可视图形表示? - How can I view the visual graph representation of the nodes created from a Neo4J Java Application? Neo4j graph.index()。forNodes找不到节点 - Neo4j graph.index().forNodes not finding nodes neo4j:用一个节点替换具有相同属性的多个节点 - neo4j: Replace multiple nodes with same property by one node Neo4j中的加权图 - Weighted graph in Neo4j 在Neo4j中,如何查找图是一个连接的还是多个不相交的 - In Neo4j ,how to find if graph is one connected or multiple disjoint 如何从Java获取Neo4j图形数据库的节点数,如何从磁盘存储和重用graphdb? - How can I get the number of nodes of a Neo4j graph database from java and can we store and reuse graphdb from disk?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM