Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么要创建[关系]在Neo4j中创建2个空节点?_Neo4j_Cypher_Relationship - Fatal编程技术网

为什么要创建[关系]在Neo4j中创建2个空节点?

为什么要创建[关系]在Neo4j中创建2个空节点?,neo4j,cypher,relationship,Neo4j,Cypher,Relationship,我首先创建这个2: CREATE (user1:Person {name:"User1"}) CREATE (user2:Person {name:"User2"}) 当我尝试的时候 CREATE (user1)-[:FOLLOWS]->(user2) 它创建了两个空节点,没有名称,也没有任何与FOLLOW相关的内容,但是节点“User1”和“User2”从来没有因为我关联它们的简单意图而受到祝福 为什么这个简单的东西不起作用?您正在分别处理这些语句。user1和user2是应用于特

我首先创建这个2:

CREATE (user1:Person {name:"User1"})

CREATE (user2:Person {name:"User2"})
当我尝试的时候

CREATE (user1)-[:FOLLOWS]->(user2)
它创建了两个空节点,没有名称,也没有任何与FOLLOW相关的内容,但是节点“User1”和“User2”从来没有因为我关联它们的简单意图而受到祝福


为什么这个简单的东西不起作用?

您正在分别处理这些语句。
user1
user2
是应用于特定cypher语句的标识符。在执行最后一条语句时,cypher不再具有对
user1
user2
的引用

你可以写

match (u1:Person {name:"User1"}), (u2:Person {name:"User2"})
create (u1)-[:FOLLOWS]->(u2)
这将找到您以前创建的节点,并使用
:FOLLOWS
关系将它们连接起来

因此,当您刚刚指定标识符int eh create语句时,它将匹配每个节点并将它们连接起来