0
votes

This question is similar to this: create relationships between nodes in parallel and this Neo4j: Best way to batch relate nodes using Cypher?

I would like to parameterize a batch for creating relationships using a Cypher query and Neo4jClient (a c# client for Neo4j).

How would I write this out (specifically focusing on performance) - i.e. using only match and create statements and not Merge as merge ends up timing out for some reason?

I was thinking I could do something like this ( as stated in that second SO link)

MATCH (s:ContactPlayer {ContactPrefixTypeId:{cptid}})
MATCH (c:ContactPrefixType {ContactPrefixTypeId:{cptid}})
CREATE c-[:CONTACT_PLAYER]->s

with params:

{
    "query":...,
    "params": {
        "cptid":id1
     }
}

But this doesn't work, because it's trying to match the property as an Array.

I modified it to use WHERE x.Y IN {params} but this was extremely slow. The second recommendation was to try to use the transactional endpoint for Neo4j but I'm unsure how to do that with Neo4jClient.

This was the recommendation from the 2nd SO link above:

{
    "statements":[
        "statement":...,
        "parameters": {
            "cptid":id1
        },
        "statement":...,
        "parameters": {
            "cptid":id2
        }
    ]
}    

I did see this pull request but did not see that it had been implemented yet: https://github.com/Readify/Neo4jClient/pull/26

Without transaction support, is there another way to do this?

1

1 Answers

0
votes

What's the performance when you use the query below?

USING PERIODIC COMMIT 1000
MATCH (s:ContactPlayer), (c:ContactPrefixType)
WHERE s.ContactPrefixTypeId = c.ContactPrefixTypeId
CREATE c-[:CONTACT_PLAYER]->s

If you want to try out the periodic commit statement, you'll have to use version 2.1.0-M1 for now. Otherwise, you can leave it out.