neo4jclient C# and CALL {} IN TRANSACTIONS syntax

Using the C# neo4jclient how can I formulate the following cypher query (possible since neo4j 4.4)

MATCH (n:Foo) where n.foo='bar'
CALL { WITH n
DETACH DELETE n
} IN TRANSACTIONS OF 10000 ROWS;

Best regards

Andreas

2 answers

  • answered 2022-01-08 14:46 Lukasmp3

    I suggest two options:

    1. Use apoc procedure apoc.periodic.iterate
    CALL apoc.periodic.iterate(
      "MATCH (n:Foo) WHERE n.foo='bar' RETURN n",
      "DETACH DELETE n",
      {batchSize: 10000}
    );
    

    More about https://neo4j.com/labs/apoc/4.2/overview/apoc.periodic/apoc.periodic.iterate/

    1. Without apoc
      Run the following query in the while cycle as long as the return value is higher then zero.
    MATCH (n:Foo)
    WHERE n.foo='bar'
    WITH n LIMIT 10000
    DETACH DELETE n
    RETURN count(*) AS numOfDeletedNodes
    

    In both cases, you should have index on Foo.foo property or the query may take really a long time.

  • answered 2022-01-12 15:12 Charlotte Skardon

    You need to get yourself version 4.1.20 of the client then you can use it like this:

    client.Cypher
      .Match("(n:Foo)").Where("n.foo='bar'")
      .Call("{ WITH n DETACH DELETE n}")
      .InTransactions(10000);
    

    It wasn't in 4.1.19 so you'll need the very latest version.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum