cancel
Showing results for 
Search instead for 
Did you mean: 

Neo4j Deprecated Binding Relationships Issue

anchit
Node

Hey guys,

This is my first time posting here so please bare with me if this post's format isn't up to standard. Basically, I am trying to get all of the paths of varying lengths from a node up to its parents.

This is the query that I was using to get my result and it is working perfectly but it gives me this 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 ('r') 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 r)

Cypher Query:
</MATCH path = (n:Patent)<-[r:PATENT_REFERENCES*]-(p1:Patent) where n.uuid='524b2129-b661-46fb-9a9a-60adf23cf2dd' return distinct length(path) as Path_Length, [n in nodes(path)|n.uuid] as the_path order by length(path)>

I am trying to make a new query which will give me the same output but won't be deprecated in future versions. Can someone please help me convert this query so that this warning does not pop up.

My current progress:
</MATCH p = (n:Patent{uuid:'524b2129-b661-46fb-9a9a-60adf23cf2dd'})<-[r:PATENT_REFERENCES]-(p1:Patent) with * return distinct length(p) as Path_Length,[x in nodes(p)|x.uuid] as the_path;>

This query executes but it only gives paths from the node to its immediate parents and all of the paths that I get are of length 1 whereas the previous query produced paths of varying lengths 1,2, and 3.

I am using Neo4j Desktop to execute my queries. You can imagine that this query is running on (Patent)-(PATENT_REFERENCES)->(Patent) type of connections.

1 REPLY 1

anthapu
Graph Fellow

The reason it is saying deprecated is because you are assigning a variable to the relationship. Change it to

MATCH path = (n:Patent)<-[:PATENT_REFERENCES*]-(:Patent) 
WHERE n.uuid='524b2129-b661-46fb-9a9a-60adf23cf2dd' 
return length(path) as Path_Length, [n in nodes(path)|n.uuid] as the_path order by length(path)

This should not give you warning. It is deprecated as the number of relationships and nodes in the path can be indeterminate, if you assign a variable name to it, it becomes difficult to get all the different values associated with same variable name.