Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
08-27-2020 08:18 AM
I have a list of words that I want to use as seed labels in Neo4j.
These labels are renewed everyday so I would like to automate my Cypher requests.
Here is the list I have today:
List : list_of_labels = ['crise sanitaire', 'face crise', 'confinement avril', 'crise coronavirus', 'virus guerre']
I tried this with variables in my Cypher requests:
def create_seed_property(tx, i): j = 0 while j < len(list_of_labels): tx.run(" MATCH (n:ARTICLE {label: $i}) SET n.seed_label = $j RETURN n ") j +=1
And next I did this:
for i in list_of_labels: session.read_transaction(create_seed_property(i))
I don't know where I'm wrong.
08-27-2020 11:07 AM
You can use UNWIND to process elements of a list. Provided you pass the list_of_labels as a parameter, you can process it like so:
UNWIND $list_of_labels as seed_label
MATCH (n:ARTICLE {label: $i})
SET n.seed_label = seed_label
RETURN n
All the sessions of the conference are now available online