0

When I call this:

MATCH (node:Wallet)
WITH collect(node) AS nodes
CALL apoc.algo.pageRankWithConfig(nodes,{types:'SendTo'}) YIELD node, score
WITH nodes, collect({id:toString(id(node)),score:score}) as ranks
call apoc.map.groupBy(ranks,'id') as ranksById
CALL apoc.algo.closeness(['SendTo'],nodes,'INCOMING') YIELD node, score
RETURN node, ranksById[toString(id(node))] as rank, score

this error is thrown:

Invalid input 'a': expected whitespace, comment, result fields of a procedure, LOAD CSV, START, MATCH, UNWIND, MERGE, CREATE, SET, DELETE, REMOVE, FOREACH, WITH, CALL, RETURN, UNION, ';' or end of input (line 5, column 35 (offset: 224))
"call apoc.map.groupBy(ranks,'id') as ranksById"
                                   ^

When I tried to call it in this way:

MATCH (node:Wallet)
WITH collect(node) AS nodes
CALL apoc.algo.pageRankWithConfig(nodes,{types:'SendTo'}) YIELD node, score
WITH nodes, collect({id:toString(id(node)),score:score}) as ranks
call apoc.map.groupBy(ranks,'id') YIELD values
CALL apoc.algo.closeness(['SendTo'],nodes,'INCOMING') YIELD node, score
RETURN node, values[toString(id(node))] as rank, score 

The error is: There is no procedure with the name `apoc.map.groupBy` registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.

When I checked with call apoc.help('apoc.map.groupBy'), the method is registered, with signature apoc.map.groupBy(values :: LIST? OF ANY?, key :: STRING?) :: (MAP?).

How should I call apoc.map.groupBy correctly?

Aqqqq
  • 816
  • 2
  • 10
  • 27

1 Answers1

1

This is because apoc.map.groupBy() is a function, not a procedure. Neo4j 3.1 introduced custom user functions (which can be called inline as expressions and don't need CALL or YIELD), and so a number of procedures were changed to functions for better flexibility.

Change your CALL line to be a WITH, like this:

WITH nodes, apoc.map.groupBy(ranks,'id') as values
...
InverseFalcon
  • 29,576
  • 4
  • 38
  • 51