Pregunta

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
¿Fue útil?

Solución

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;
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top