2014-06-13 85 views
4

較新版本的Cypher不再喜歡我的OPTIONAL MATCH子句。 Cypher 2.1此查詢的正確版本是什麼?升級到neo4j 2.1打破了Cypher查詢

Cannot add labels or properties on a node which is already bound (line 1, column 104) 
"MATCH (n1:Entity {key:"bloomberg michael"})-[r1:RELATED_TO]-(n2:Entity) 
WITH n1, r1, n2 
OPTIONAL MATCH (n2:Entity)-[r2:RELATED_TO]-(n3:Entity) 
RETURN n1, r1, n2, count(n3), labels(n1), labels(n2) 
ORDER BY n2.relevance DESC 
LIMIT 50" 

回答

4

你可以嘗試

MATCH (n1:Entity {key:"bloomberg michael"})-[r1:RELATED_TO]-(n2:Entity) 
WITH n1, r1, n2 
OPTIONAL MATCH (n2)-[r2:RELATED_TO]-(n3:Entity) 
RETURN n1, r1, n2, count(n3), labels(n1), labels(n2) 
ORDER BY n2.relevance DESC 
LIMIT 50 
+0

感謝。它是OPTIONAL MATCH子句中的「實體」標籤。 – ahoffer

+0

實際上,「可選匹配」和「匹配」都以這種方式發生了變化,我遇到了這個問題,我們在中間件中生成「匹配」查詢,並且不知道標籤是否將在稍後的查詢中定義用它。 –