0

How to merge nodes in a query with apoc.refactor.mergeNodes([]) and then do something about the merged node? When I use this:

WITH w2, minW, minW {.*} as snapshot
call apoc.refactor.mergeNodes([minW,w2]) YIELD reW
SET reW.first_seen =...

This error is thrown: Unknown procedure output: reW

If instead of using reW, minW is used, the error says that the variable has already been decleared

Aqqqq
  • 816
  • 2
  • 10
  • 27

1 Answers1

4

Procedures declare the variables yielded by them. You can either check for the yielded variable in the documentation (which in this case won't help, it's not shown for this procedure in APOC docs, I'll try to get a fix in), or call apoc.help() and pass in the procedure name, like:

call apoc.help('apoc.refactor.mergeNodes')

The signature output should show the variable yielded. In this case, it's node, so use YIELD node, though you can alias it using as however you like.

InverseFalcon
  • 29,576
  • 4
  • 38
  • 51
  • Apparently the merge violates the constraint I set. Is there any way around that? – Aqqqq Apr 25 '17 at 11:21
  • you mean something like this https://github.com/neo4j-contrib/neo4j-apoc-procedures/issues/397 – Tomaž Bratanič Apr 25 '17 at 12:18
  • No it seems more like something which would come up when neo4j is trying to create a repeated node according to constraint. The error output is this: Failed to invoke procedure `apoc.refactor.mergeNodes`: Caused by: org.neo4j.graphdb.ConstraintViolationException: Node 50783 already exists with label Wallet and property "primWallAddr"=[1CzbWrLswUJVCJZjHecp6Q4ce6VrGNAXoT] – Aqqqq Apr 25 '17 at 16:32