I want to know if it is possible when using UNWIND to only iterate a certain part of the query instead of iterating the whole thing.
This is a simplified example but gets my point across
UNWIND $user AS user CREATE (u:User) SET u += user WITH u // Attaching house to user UNWIND $houses AS house MATCH (h:House) WHERE h.address = house.address CREATE (u)-[:OWNS]->(h) WITH u // Attaching car to user UNWIND $cars AS car MATCH (c:Car) WHERE c.brand = car.brand CREATE (u)-[:OWNS]->(c) RETURN DISTINCT c
In this example, I am creating a new user node and attaching the houses and cars the user owns. The parameter $user is only single but for parameter $houses and $cars can have multiple. Thus if I use the above query I will create duplicate relationship between user and car. I know this can be solved by using MERGE instead but MERGE is more costly than CREATE. Back to my original statement;
I want to know if it is possible when using UNWIND to only iterate a certain part of the query instead of iterating the whole thing? (i.e. when using UNWIND $houses just iterate the attaching house part of the query)
Thanks in advance