繁体   English   中英

Cypher -Neo4j在可变长度路径中设置节点属性值

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM