Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-23-2022 01:15 PM - edited 12-23-2022 01:22 PM
Solved! Go to Solution.
12-23-2022 02:44 PM
Then you can do something like this:
WITH [$docStart] + split($doc,"") + [$docEnd] as symbols
UNWIND symbols as symbol
MERGE (s:SYMBOL {name:symbol})
ON CREATE SET s.count=1
ON MATCH SET s.count = coalesce(s.count,0) + 1
WITH collect(s) AS newSymbols
WITH newSymbols, size(newSymbols) AS nodeCount
CALL {
with newSymbols, nodeCount
//do processing
}
//do more processing...
or, you can pass them to a procedure with a 'call' statement.
12-23-2022 02:27 PM
You can't reference a variable that you define on the same line. Try this instead:
WITH [$docStart] + split($doc,"") + [$docEnd] as symbols
UNWIND symbols as symbol
MERGE (s:SYMBOL {name:symbol})
ON CREATE SET s.count=1
ON MATCH SET s.count = coalesce(s.count,0) + 1
WITH collect(s) AS newSymbols
RETURN newSymbols, size(newSymbols) AS nodeCount
12-23-2022 02:37 PM
Thanks for the quick reply. My problem is that I need to define nodeCount as as a variable together with newSymbols to use in a subsequent CALL to create a linked list using nodeCount and nodeCount + 1 to specify nodes from newNodes. I'm pretty new at Cypher and may be doing it all wrong.
12-23-2022 02:44 PM
Then you can do something like this:
WITH [$docStart] + split($doc,"") + [$docEnd] as symbols
UNWIND symbols as symbol
MERGE (s:SYMBOL {name:symbol})
ON CREATE SET s.count=1
ON MATCH SET s.count = coalesce(s.count,0) + 1
WITH collect(s) AS newSymbols
WITH newSymbols, size(newSymbols) AS nodeCount
CALL {
with newSymbols, nodeCount
//do processing
}
//do more processing...
or, you can pass them to a procedure with a 'call' statement.
12-23-2022 03:04 PM
Perfect. I tried the two WITH statements, but got the second one wrong (failed to include newSymbols in the second one.) You showed my error exactly. Thanks for the time & trouble!
All the sessions of the conference are now available online