cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Problems with collect?

rmasrani
Node Clone

Dear Community. I have 2 cyphers which - on the surface - appear to be identical except for the property they are setting. The first one works as it should; the second "clone" does not. Could you have a look:

Query 1. Goal is to add the root PROG node (t) to all its descendents to level 20
MATCH (t:PROG {isJob: true})
CALL apoc.path.subgraphNodes(t, {
relationshipFilter: "USES>",
minLevel: 1,
maxLevel: 20
}) yield node
WITH node, collect(t.label) as jl
SET node.inUse = true, node.hasJobList = true, node.jobList = jl;

works perfectly
Query 2: same thing - except that the root node is a "TRAN"
MATCH (t:TRAN)
WITH t
WHERE t.label <> "JOB"
CALL apoc.path.subgraphNodes(t, {
relationshipFilter: "USES>",
minLevel: 1,
maxLevel: 20
}) yield node
WITH t, node, collect(t.label) as tcl
SET node.inUse = t.inUse, node.hasTcodeList = true, node.tCodeList = tcl;

Only seems to store the last value in tCodeList instead of a collection. I think that the answer is probably right in front of me - but it is eluding me, Any help would be much appreciated. P.S. if there is a better way to cash the root of the tree, I would love to know.

2 REPLIES 2

Because you have t as an aggregation key so you get one row aggregated per t and node.

Remove the t as agg key and you get all t‘s for the node aggregated

rmasrani
Node Clone

I feel SOOO stupid. Thanks!!!