[英]Cypher -Neo4j Set the node attribute value in Variable length paths
I am new to neo4j , I have the following situation 我是neo4j的新手,我有以下情况
match (c:customer{id:'12345'})-[r:buys]->(b:item)
with b,b.total as z
match (b)-[same:*1..z)]->(d)
return d
In the above query z is an integer,But the above query is not working, 在上面的查询中z是一个整数,但是上面的查询不起作用,
I would appreciate all helps and suggestions, Thanks in advance 我将不胜感激所有的帮助和建议,在此先感谢
You cannot use variable for path lengths. 您不能将变量用于路径长度。 A workaround for that would be: 一种解决方法是:
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
Replace the 9999 by a kind of global upper limit suitable for your use case. 用适合您的使用情况的一种全局上限替换9999。 Be warned, this might be pretty inefficient. 请注意,这可能效率很低。 In this case it might be better to send 2 Cypher statements: 在这种情况下,最好发送2个Cypher语句:
match (c:customer{id:'12345'})-[r:buys]->(b:item) return id(b), b.total as z
For the second query insert the value for z via string concatenation: 对于第二个查询,通过字符串串联插入z的值:
match (b)-[same:*1..<z>)]->(d) return d
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.