Receiving a warning "This feature is deprecated..." when using `()-[]->()`

I'm didn't find a good and, at the same time, clean way to search complete paths that constains a specific node. The solution that I reach is giving me the following warning:

  • This feature is deprecated and will be removed in future versions.
    Binding relationships to a list in a variable length pattern is deprecated. (Binding a variable length relationship pattern to a variable ('r1') 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 r1)
EXPLAIN MATCH p=(n1:WaterNode)-[r1:CONNECTED*]->(n:WaterNode{name:"Pisão", type:"Barragem"})-[r2:CONNECTED*]->(n2:WaterNode)

Hi @bmalbusca

What variable do you want to return? All?
If all you want in the return value is p, then you don't need any other variables.

EXPLAIN MATCH p=(:WaterNode)-[:CONNECTED*]->(:WaterNode{name:"Pisão", type:"Barragem"})-[:CONNECTED*]->(:WaterNode)

Hello @koji , I'm trying to collect all paths p which uses the relation CONNECTED and contains a specific node WaterNode{name:"Pisão", type:"Barragem

// Find all full paths that contains a specific water node
// Ex. name:"Pisão", type:"Barragem"
MATCH p=(n1:WaterNode)-[r1:CONNECTED*]->(n:WaterNode{name:"Pisão", type:"Barragem"})-[r2:CONNECTED*]->(n2:WaterNode)
RETURN collect(p)

I'm not sure about what i'm doing wrong when you say then you don't need any other variables..

I'm new with this, but * gives all the link between 2 nodes, rigth? With (n1:WaterNode)-[r1:CONNECTED*]->(n:WaterNode{name:"Pisão", type:"Barragem"}) I'm getting all paths from back of the node and with (n:WaterNode{name:"Pisão", type:"Barragem"})-[r2:CONNECTED*]->(n2:WaterNode) I'm getting all paths upfront.
Thank you

Hi @bmalbusca

Variables are only used for Where comparisons and returns.
If you don't use them, you don't need variables.

  • gives all the link between 2 nodes

If the depth of the graph is predictable, it is best to write down the limit.

1 Like