0

The following query results in 10 updated nodes:

MATCH (a:ns3__Organization)-[r:ns4__isDomiciledIn]->(b:Resource)
WITH a,b LIMIT 10
SET a.isDomiciledIn = b.Country

I'm trying to apply it to my whole graph with apoc.periodic.commit through the following query:

CALL apoc.periodic.commit("
MATCH (a:ns3__Organization)-[r:ns4__isDomiciledIn]->(b:Resource)
WITH a,b LIMIT $limit
SET a.isDomiciledIn = b.Country
", { limit : 50000});

Somehow it results in 0 update. What am I doing wrong?

Thanks for your help.

jvilledieu
  • 535
  • 2
  • 12

1 Answers1

0

You should try this one :

CALL apoc.periodic.commit("
MATCH (a:ns3__Organization)-[r:ns4__isDomiciledIn]->(b:Resource)
WHERE NOT a.isDomiciledIn = b.Country 
WITH a,b LIMIT $limit
SET a.isDomiciledIn = b.Country
RETURN count(*)
", { limit : 50000});

You errors :

  • no count(*) at the end of your query. SO your query never ends
  • no WHERE clause to filter the result to only nodes that are not yet updated
logisima
  • 7,340
  • 1
  • 18
  • 31
  • Thanks Benoit ! For some reason this query hangs and the database is not updated. Do you know what's going on? – jvilledieu Sep 04 '18 at 16:02
  • By looking at the code, if you don't have a result (or a Numeroc result), the count is `0`. So your query is doing only one loop. – logisima Sep 04 '18 at 16:09
  • for reference : https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/3.4/src/main/java/apoc/periodic/Periodic.java#L120-L133 – logisima Sep 04 '18 at 16:10