Cypher和Neo4j:使用Cypher请求进行循环

问题描述

我有一个要在Neo4j中用作种子标签的单词列表。

这些标签每天都会更新,因此我想自动执行Cypher请求。

这是我今天的清单:

列表:list_of_labels = ['crise sanitaire','face crise','confinement avril','crise coronavirus','virus guerre']

我在Cypher请求中使用变量尝试了此操作

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

然后我这样做:

for i in list_of_labels: session.read_transaction(create_seed_property(i))

我不知道我哪里错了。

[附录]

我想为'crise sanitaire'添加seed_label = 0,为'face crise'添加seed_label = 1,我想为列表中的每个字符串添加seed_label属性list_of_labels列表。但是该列表每天都会更新,这就是为什么我尝试将其自动化。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)