Suppose we have this query:
match (n:Intersection) WHERE NOT (n)<-[:RTREE_REFERENCE]-() RETURN n
It returns nodes, but how can we return it as a LIST of all nodes returned? i.e. [node1, node2, node3]. The procedure I'm using requires an input parameter which needs to be in collections/list format
match (n:Intersection) WHERE NOT (n)<-[:RTREE_REFERENCE]-() with n CALL spatial.addNodes("network",n) yield node return node
Type mismatch: expected Collection<Node> but was Node
If you change your query to:
MATCH (n:Intersection)
WHERE NOT (n)<-[:RTREE_REFERENCE]-()
RETURN COLLECT(n)
then it will return the list of nodes.
So the second query will look like this:
MATCH (n:Intersection)
WHERE NOT (n)<-[:RTREE_REFERENCE]-()
WITH COLLECT(n) AS nodesList
CALL spatial.addNodes("network", nodesList) YIELD node
RETURN node
See https://neo4j.com/docs/cypher-manual/current/functions/aggregating/#functions-collect
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With