Question

I have query with variable length path. Is it possible to use relation in where for filtering paths (without using with), for example like this:

match (u:user{id:1})-[r*1..2]->(n) where u-[r[0]]-(:event) return n

This will work but will be slower:

match (u:user{id:1})-[r*1..2]->(n) with u, r[0] as r0, n where u-[r0]-(:event) return n
Was it helpful?

Solution

EDIT

This should return the same result, but without a WITH clause:

MATCH (u:user{id:1})-[]->(e:event)
OPTIONAL MATCH (e)-[]->(x)
RETURN coalesce(x, e) as n;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top