[英]Cypher -Neo4j Set the node attribute value in Variable length paths
我是neo4j的新手,我有以下情況
match (c:customer{id:'12345'})-[r:buys]->(b:item)
with b,b.total as z
match (b)-[same:*1..z)]->(d)
return d
在上面的查詢中z是一個整數,但是上面的查詢不起作用,
我將不勝感激所有的幫助和建議,在此先感謝
您不能將變量用於路徑長度。 一種解決方法是:
match (c:customer{id:'12345'})-[r:buys]->(b:item)
with b,b.total as z
match p=(b)-[same:*1..9999)]->(d)
where length(p)=z
return d
用適合您的使用情況的一種全局上限替換9999。 請注意,這可能效率很低。 在這種情況下,最好發送2個Cypher語句:
match (c:customer{id:'12345'})-[r:buys]->(b:item) return id(b), b.total as z
對於第二個查詢,通過字符串串聯插入z的值:
match (b)-[same:*1..<z>)]->(d) return d
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.