I want to match a path between 2 nodes where there are 0 or more of a certain type of relationship but ending in a specific different relationship, eg it should match:
(a) -> [:GRANT] -> (b)
(a) - [:MEMBER] -> () -> [:GRANT] -> (b)
(a) - [:MEMBER] -> () - [:MEMBER] -> () -> [:GRANT] -> (b)
but not
(a) - [:MEMBER] -> () - [:GRANT] -> () -> [:GRANT] -> (b)
Ive tried:
MATCH (a) - [:MEMBER *] -> () - [:GRANT] -> (b)
but it only works if there is at least one member relationship (eg the () node must exist).
Ive also tried things like this:
MATCH (a) - [:MEMBER *] -- [:GRANT] -> (b)
but they have syntax errors.
Is there a way to optionally match a relationship while ensuring the chain ends in a specific second relationship type?