Deprecated query

My query that I had for sometime seems to be deprecated (it works though but eventually might not) and want to know how I can get the same output with the right query. Here is my query

MATCH (root:Person {lns_neo4j_id:'9'})-[lns_relationship*1..3]->(a:Person) UNWIND lns_relationship AS rs RETURN DISTINCT startNode(rs) as Person, rs as Relationship, endNode(rs) as RelatedPerson Order by startNode(rs).lns_neo4j_id

Any suggestions please.

Hello @rangan and welcome to the Community!

What version of Neo4j database are you using?

What is the content of the deprecation warning that you are seeing?

Elaine

Hi @elaine_rosenber

The version is 4.2 and the error/warning is as follows:

Binding relationships to a list in a variable length pattern is deprecated.
(Binding a variable length relationship pattern to a variable ('lns_relationship') is deprecated
and will be unsupported in a future version. Appreciate your feedback

Thanks
Bye

Here is what engineering recommends:

Use relationships() function on a path - MATCH - Cypher Manual

Elaine

@rangan You can use the apoc.convert.toTree to get the associated nodes. Below is the link which might help you.

Thanks