Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
08-13-2020 05:29 AM
I'm reading through the book Graph Algorithms
, and before running this query (page 60):
MATCH p=(email:Email {id:'6'})<-[:REPLY_TO*1..4]-(:Reply)<-[:SENT]-(replier)
RETURN replier.username AS replier, length(p) - 1 AS depth
ORDER BY depth
I received 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 ('REPLY_TO') 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 REPLY_TO)
What modifications does the original query need to make it current?
Thank you.
08-13-2020 06:06 AM
Hello @timkofu
MATCH p = (email:Email {id:'6'})<-[:REPLY_TO*1..4]-(:Reply)<-[:SENT]-(replier)
RETURN replier.username AS replier, length(relationships(p)) - 1 AS depth
ORDER BY depth
Regards,
Cobra
08-14-2020 05:46 AM
Turns out I had a typo in my query [REPLY_TO*1..4]
instead of [:REPLY_TO*1..4]
. Thanks for trying to help all the same.
08-14-2020 05:48 AM
Oh I see, good job
08-15-2020 06:09 AM
But there's a learning opportunity here; the query Neo4j proposes MATCH p = (...)-[...]-(...) WITH *, relationships(p) AS REPLY_TO
, when would it be appropriate to use? What's a use-case for it?
08-15-2020 06:12 AM
Personaly, I use relationships(p)
when for example I need to get all nodes of path, or to get all the properties of path. When you have a small path (2 relations and 3 nodes), you are not force to use it but it becomes necessary when you have longer path
03-10-2022 06:34 AM
@Cobra I'm having a similar issue as Timothy, but still can't get your suggested query to work. I'm basically trying to find relationships within 2 hops but getting the following. Any ideas?
03-10-2022 06:42 AM
Hello @ryan.saxton
The function relationships(z)
returns a list of relationships so you must use size(relationships(z))
if you want the size of the list. The function length()
can be used directly on z
since it's a path
and not a list
. So you there are size(relationships(z))
or length(z)
.
Regards,
Cobra
All the sessions of the conference are now available online