Reputation: 4624
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
Upvotes: 0
Views: 687
Reputation: 39925
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
Upvotes: 1