cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

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

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

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.