Reputation: 3499
I'm having trouble finding a summation of all the weights associated with relationships. If I have a graph and the distance between each node has a property called weight, say I wanted to find all the nodes and order by relationship weight.
MATCH (album:Album)-[relationship]-(tags:Word)
WITH album, COLLECT(tags) as tags, relationship
WHERE ALL (v IN ["alpha", "bravo"] WHERE v IN EXTRACT(n in tags | n.name))
RETURN album,tags, relationship.weight as DISTANCE ORDER BY DISTANCE ASC LIMIT 15;
why am I getting an error with this? When I remove relationship it works just fine, but it says 'relationship not defined' when I add this. I want to 'ORDER BY relationship DESC LIMIT 25'. I mainly struggling with the implementation of relationship properties so I can create a weighted graph. Thank you in advice for advice and consideration.
Upvotes: 1
Views: 396
Reputation: 9952
Because the second part of your query only knows the things you tell it in your WITH
clause. In that clause you name the identifiers album
and tags
, but you don't name relationship
. So when the time comes to return, there is no such thing as relationship
.
Try adding , relationship
to your WITH
clause to bring that also into the second part of the query.
Also, please consider being consistent about capitalizing constructs of your cypher query–specifically, if you capitalize WITH
, WHERE
, and ALL
, do capitalize match
and return
. This has no bearing on how your query is implemented, but it helps us reason about queries if we abide by the conventions.
Upvotes: 3