Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-12-2019 06:36 PM
I have a query being built up through python that looks something like this:
for url in urls:
q = '''Match (u:User) Where u.id=18284
Merge (:Url {{ url:"{url}" }})<-[:CONTAINS_URL]-(u)'''
tx.run(q)
It seems wasteful to have to Match on the user over and over again. Is there a way to match it once and add all the corresponding url edges in some sort of batch?
12-13-2019 12:06 AM
The most easy way would to pass in an array parameter and use UNWIND
:
tx.run("MATCH (u:User{id:$id})
WITH u
UNWIND $urls as url
MERGE (:Url{url:url})<-[:CONTAINS]-(u)",
id=18284, urls=urls)
Note you're passing named parameters to tx.run
. Those will be resolved using the $
notation in your cypher string.
All the sessions of the conference are now available online