I have a list of context, for example ["Going out", "With Friends", "Japanese Food", ...] and I'm looking for a preference node that has a relationship of type CONTEXT_OF with ALL of these values.
Of course I can just do
MATCH (p:Preference)<-[r1:CONTEXT_OF]-(c1:Context { name: "Going out"})
MATCH (p:Preference)<-[r2:CONTEXT_OF]-(c2:Context { name: "With Friends"})
MATCH (p:Preference)<-[r3:CONTEXT_OF]-(c3:Context { name: "Japanese Food"})
...
but I wanna do it a loop style. I've tried using UNWIND, as follows:
WITH ["Going out", "With Friends", "Japanese Food"] as context
UNWIND context AS context_name
MATCH (p:Preference)<-[r:CONTEXT_OF]-(c:Context { name: context_name })
But the problem here is that the Preference node (p) must remain the same, where as the relationships and the context node variables must be different for each patterns (see r1 and c1, r2 and c2 in the first cypher, as opposed to r and c in the second cypher). In other words, I need to find preference nodes that each must be connected to ALL the contexts in the list.
Thank you