How to properly update depreciated query?

I have a query that does what I want.
Yet, it runs with warnings, but when I'm trying to adjust it to the new syntax, it doesn't work (the result is different).

Why? What am I doing wrong?

Depreciated query

match (g:Id {start_marker: 1})-[MINST*]->(leaf)
where not (leaf)-[:MINST]->()
return leaf

Result

Suggested Fix:

Binding a variable length relationship pattern to a variable ('rel') is deprecated and will be unsupported in a future version. The recommended way is to bind the whole path to a variable, then extract the relationships: MATCH p = (...)-[...]-(...) WITH *, relationships(p) AS rel

Fixed query

match p = (g:Id {start_marker: 1})-[MINST]->(leaf)
with *, relationships(p) as MINST
where not (leaf)-[:MINST]->()
return leaf

First, I feel you are missing a ":" in the relationship part in the path. Because of that it is going to give all relationships.

Also for other aspect you might have to add EXISTS

Can you try this?

match p = (g:Id {start_marker: 1})-[:MINST*]->(leaf)
where not EXISTS ((leaf)-[:MINST]->())
return leaf
2 Likes