Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-17-2020 08:19 AM
Hi,
I am trying to use "apoc.do.when" function, and I am probably doing something wrong.
Basically, We are trying to copy labels from one node to a group of nodes that meet a certain condition.
I want to run the SET command only if I found missing labels and I tried to do something like that:
MATCH(A:<label> {name:<name>})
MATCH(B:<label> {name:<name>})
CREATE(A)-[w0:data]->(B)
WITH A, B, labels(A) as labelsA, labels(B) as labelsB WITH A, B, [uniqlabelsB in labelsB where not (uniqlabelsB in labelsA) and uniqlabelsB STARTS WITH 'group' | uniqlabelsB] as missingLabelsFromNode1, [uniqlabelsA in labelsA where not (uniqlabelsA in labelsB) and uniqlabelsA STARTS WITH 'group' | uniqlabelsA] as missingLabelsFromNode2
CALL apoc.do.when(size(missingLabelsFromNode1) > 0,"MATCH(FA) where FA.family_name STARTS WITH A.family_name set FA:B.base_group", "", {A:A, B:B}) YIELD value
RETURN A,B
And I got this error message neo4j.exceptions.ClientError: Failed to invoke procedure
apoc.do.when: Caused by: org.neo4j.exceptions.SyntaxException: Invalid input '.'
What am I doing wrong?
How can I get the base_group parameter from the B node and set it as a label for all the FA nodes?
I also tried to use the missingLabelsFromNode1 variable but it ignores from this parameter also.
Thanks in advance.
Dan
11-27-2020 10:18 AM
Dan,
Can you provide Create statements to build a simple test case? I tried reproducing the issue, from the code, but can't.
Robert
11-28-2020 12:40 PM
I'm not sure, but it does seem unwise to have the fragment (A:A)
and (B:B)
since you are using the capital letter for both a Label and a variable for a node.
It's against the style guidelines and feels confusing to me.
All the sessions of the conference are now available online