Why is this query invalid?

lingvisa
Graph Fellow
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 (apoc.periodic.iterate - APOC Documentation😞

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

mihaque313
Node Link

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:

View solution in original post

2 REPLIES 2

mihaque313
Node Link

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:

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.