2013-11-23 38 views
0

我還沒有找到關於此問題或在Neo4j手冊中發現任何評論。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 = 'A1' 
return distinct s.subject_id; 
==> +--------------+ 
==> | s.subject_id | 
==> +--------------+ 
==> +--------------+ 
==> 0 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 

回答

2

我想你跑進標識符暗號路徑的唯一性。

在相同的路徑中,兩個不同的標識符(如果未預先綁定的話)將不會指向同一個節點。

在你的第一個例子中,路徑的兩邊都被綁定(到同一個節點),在最後一個例子中你有兩個不同的節點,一個綁定到n另一個綁定到s

在第二個示例中,您最終將綁定到與ns綁定的相同節點,該密碼不在路徑中執行。

+0

謝謝,我明白了。擺脫關係觀點是具有挑戰性的。 – user3025434

相關問題