# Deprecated query

**URL:** <https://community.neo4j.com/t/deprecated-query/35645>\
**Category:** Cypher\
**Created:** [March 21, 2021, 6:44pm UTC](https://community.neo4j.com/t/deprecated-query/35645 "2021-03-21T18:44:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rangan](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/rangan/32/3859_2.png) [@rangan](https://community.neo4j.com/u/rangan)\
**Post date:** [March 21, 2021, 6:44pm UTC](https://community.neo4j.com/t/deprecated-query/35645/1 "2021-03-21T18:44:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![elaine\_rosenber](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/elaine_rosenber/32/27409_2.png) [@elaine\_rosenber](https://community.neo4j.com/u/elaine_rosenber)\
**Post date:** [March 22, 2021, 12:01pm UTC](https://community.neo4j.com/t/deprecated-query/35645/2 "2021-03-22T12:01:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rangan](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/rangan/32/3859_2.png) [@rangan](https://community.neo4j.com/u/rangan)\
**Post date:** [March 22, 2021, 1:14pm UTC](https://community.neo4j.com/t/deprecated-query/35645/3 "2021-03-22T13:14:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![elaine\_rosenber](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/elaine_rosenber/32/27409_2.png) [@elaine\_rosenber](https://community.neo4j.com/u/elaine_rosenber)\
**Post date:** [March 22, 2021, 2:28pm UTC](https://community.neo4j.com/t/deprecated-query/35645/4 "2021-03-22T14:28:41Z")

</div>

Here is what engineering recommends:

Use `relationships()` function on a path - [MATCH - Cypher Manual](https://neo4j.com/docs/cypher-manual/current/clauses/match/#rel-variable-in-varlength-rels)

Elaine

---

<div class="post-metadata">

**Author:** ![dksingh1](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/dksingh1/32/17412_2.png) [@dksingh1](https://community.neo4j.com/u/dksingh1)\
**Post date:** [March 25, 2021, 8:37am UTC](https://community.neo4j.com/t/deprecated-query/35645/5 "2021-03-25T08:37:51Z")

</div>

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

> **[apoc.convert.toTree - APOC Extended Documentation](https://neo4j.com/labs/apoc/4.1/overview/apoc.convert/apoc.convert.toTree/)**
>
> This section contains reference documentation for the apoc.convert.toTree procedure.

Thanks
