Reputation: 3934
I have the following problem:
I have a MATCH
clause like this one:
MACTH (A)-[*1..]->(B)
Now, if this pattern matches, I need to somehow duplicate the -[*1..]->
part and replace all node in it tat have a specific type with nodes of another type.
for example if I had this graph:
(X1:A)-[:r]->(X2:B)-[:r]->(X3:E)-[:r]->(X4:A)
I might want to get this graph after applying a rule MACTH (A:A)-[*1..]->(B:A) something something
(X1:A)-[:r]->(X2:B)-[:r]->(X3:E)-[:r]->(X4:A) , (X1)-[:r]->(X5:C)-[:r]->(X3)-[:r]->(X4)
by duplicating the path between (A)
and (B)
and replacing all nodes of type B
with type C
But how can I access the -[*1..]->
part of the query?
Upvotes: 2
Views: 400
Reputation: 1338
Try this
Match (p:Person)-[:RELATED*1..]->(e)
with collect(distinct(id(e))) as ids Match (c:Country) where id(c) in ids
remove c:Country set c:NewLabel
return *
on data
Create (p:Person)-[:RELATED]->(b:Person)-[:RELATED]->(c:Client)-[:RELATED]->(e:Country) return *
Upvotes: 1