neo4j为什么在结果集中找不到开始节点?

neo4j为什么在结果集中找不到开始节点?,neo4j,match,cypher,Neo4j,Match,Cypher,我在Neo4j手册中找不到任何问题或评论 此查询返回开始节点: start n = node:node_auto_index(subject_id='A1') match (n)-[]->()<-[]-(n) return distinct n.subject_id; ==> +--------------+ ==> | n.subject_id | ==> +--------------+ ==> | "A1" | ==> +-------------

我在Neo4j手册中找不到任何问题或评论

此查询返回开始节点:

start n = node:node_auto_index(subject_id='A1')
match (n)-[]->()<-[]-(n)
return distinct n.subject_id;
==> +--------------+
==> | n.subject_id |
==> +--------------+
==> | "A1" |
==> +--------------+
==> 1 row 
start n = node:node_auto_index(subject_id='A1')
match (n)-[]->()<-[]-(s)
where s.subject_id = 'B2'
return distinct s.subject_id;
==> +--------------+
==> | s.subject_id |
==> +--------------+
==> | "B2" |
==> +--------------+
==> 1 row
start n=node:node\u auto\u index(subject\u id='A1')
匹配(n)-[]->()+--------------+
==>| n.受试者id|
==> +--------------+
==>|“A1”|
==> +--------------+
=>1行
但此查询不返回开始节点。是否有任何方法使其与其他匹配节点一起返回起始节点

start n = node:node_auto_index(subject_id='A1')
match (n)-[]->()<-[]-(s)
where s.subject_id = 'A1'
return distinct s.subject_id;
==> +--------------+
==> | s.subject_id |
==> +--------------+
==> +--------------+
==> 0 row
start n=node:node\u auto\u index(subject\u id='A1')
匹配(n)-[]->()+--------------+
==>| s.subject_id|
==> +--------------+
==> +--------------+
=>0行
为了确保语法正确,前面的查询适用于除开始节点外的其他节点:

start n = node:node_auto_index(subject_id='A1')
match (n)-[]->()<-[]-(n)
return distinct n.subject_id;
==> +--------------+
==> | n.subject_id |
==> +--------------+
==> | "A1" |
==> +--------------+
==> 1 row 
start n = node:node_auto_index(subject_id='A1')
match (n)-[]->()<-[]-(s)
where s.subject_id = 'B2'
return distinct s.subject_id;
==> +--------------+
==> | s.subject_id |
==> +--------------+
==> | "B2" |
==> +--------------+
==> 1 row
start n=node:node\u auto\u index(subject\u id='A1')
匹配(n)-[]->()+--------------+
==>| s.subject_id|
==> +--------------+
==>|“B2”|
==> +--------------+
=>1行

我认为您在密码路径中遇到了标识符唯一性

在同一路径中,两个不同的标识符(如果没有预先绑定)不会指向同一节点

在第一个示例中,路径的两侧都绑定到(同一个节点),在最后一个示例中,您有两个不同的节点,一个绑定到
n
,另一个绑定到
s


在第二个示例中,您最终将同一个节点绑定到
n
s
,这是cypher在路径中不做的。

谢谢,我现在明白了。打破关系观点很有挑战性。