Reputation: 355
If I have a cypher query that unwinds a parameter, everything after that portion of the query is called x number of times of the unwind. I'd like to figure out a way to end the unwind and continue with other things.
MATCH (thing:Thing)
UNWIND { names } AS name
CREATE thing-[:HAS_NAME]-(n:Name {name: name})
//done with the unwind
WITH (thing)
CREATE thing[:HAS_AGE]-(a:Age {age: 20})
In the above example, I will end up with two thing-[:HAS_AGE]->() relationships because of the unwind. Do I have to split this into separate statements?
Upvotes: 2
Views: 3153
Reputation: 11216
After the unwind you have two rows. If you re-collapse thing
before moving on you will then have a single again.
MATCH (thing:Thing)
UNWIND { names } AS name
CREATE thing-[:HAS_NAME]-(n:Name {name: name})
//done with the unwind
WITH distinct thing
CREATE thing[:HAS_AGE]-(a:Age {age: 20})
Upvotes: 4