I am new to neo4j , I have the following situation
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,
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. Be warned, this might be pretty inefficient. In this case it might be better to send 2 Cypher statements:
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:
match (b)-[same:*1..<z>)]->(d) return d
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.