Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-16-2021 02:42 AM
Hi. I'm learning neo4j and I have to make a simple query, but I'm not able to make it.
Suppose to have the graph below.
I want to return all the nodes connected to the node A
and the maximum of the values on the edges between two consecutive nodes(which is an attribute of the relation). I show an example in the picture below.
I did it for path of length one with this query:
MATCH (p {id:"A"})<-[r:HAS]-(t)
RETURN p,max(r.value),t
But I don't know how to make a query for a path longer than one, just because I can't do
MATCH (p {id:"A"})<-[r:HAS*]-(t)
RETURN p,max(r.value),t
I got this error : Type mismatch: expected Map, Node, Relationship, Point, Duration, Date, Time, LocalTime, LocalDateTime or DateTime but was List
Solved! Go to Solution.
10-16-2021 04:49 AM
Hello @AjejeBrazorf and welcome to the Neo4j community
Sorry, new syntax, I always forget about it.
MATCH path=(a {id:"A"})<-[:HAS*]-(b)
RETURN a,b, max([r in relationships(path) | r.value])
Regards,
Cobra
10-16-2021 03:17 AM
Hello Cobra.
Thank you for your reply.
It gives me this error
"Can't use aggregate functions inside of aggregate functions. "
10-16-2021 04:36 AM
Yeah I have APOC. But this leads me to the same error I have reported in the question:
"Type mismatch: expected Map, Node, Relationship, Point, Duration, Date, Time, LocalTime, LocalDateTime or DateTime but was List<Relationship"
10-16-2021 04:49 AM
Hello @AjejeBrazorf and welcome to the Neo4j community
Sorry, new syntax, I always forget about it.
MATCH path=(a {id:"A"})<-[:HAS*]-(b)
RETURN a,b, max([r in relationships(path) | r.value])
Regards,
Cobra
10-16-2021 05:26 AM
Thanks a lot. This perfectly works!
Thanks for your time.
Regards
Ajeje
All the sessions of the conference are now available online