Why is this query invalid?

CALL apoc.periodic.iterate(

"MATCH (n:Article) return n.nid",

"REMOVE n.bertEmbedding",

{batchSize:30000, parallel:false, iterateList:true})

The error message:

org.neo4j.graphdb.QueryExecutionException: Variable n not defined (line 1, column 65 (offset: 64))\n"UNWIND $_batch AS _batch WITH _batch.n.nidASn.nid REMOVE n.bertEmbedding"\n ^": 1

According to the documentation, the following example query is valid (https://neo4j.com/labs/apoc/4.2/overview/apoc.periodic/apoc.periodic.iterate/):

CALL apoc.periodic.iterate(
  "MATCH (p:Person) WHERE (p)-[:ACTED_IN]->() RETURN p",
  "SET p:Actor",
  {batchSize:10000, parallel:true})

This is invalid because you are returning n.nid instead of n in the first part of query.
Your correct query should be:

ALL apoc.periodic.iterate(
"MATCH (n:Article) return n",
"REMOVE n.bertEmbedding",
{batchSize:30000, parallel:false, iterateList:true})

Cheers! :beers:
2 Likes

That's true. I misunderstood the 'return' statement in this context, which must return the whole thing in order for the 2nd statement to work properly.