我正在尝试在 neo4j 数据库中的节点之间批量创建关系。我正在尝试使用此代码,但它不起作用!
relations = [{'from': 'man', 'to': 'woman', 'properties': {'cost': 0}},
{'from': 'woman', 'to': 'baby', 'properties': {'cost': 0}]
query = """
UNWIND {{relations}} as row
MATCH (from:SINGLE_NODE {{row.from}})
MATCH (to:SINGLE_NODE {{row.to}})
CREATE/MERGE (from)-[rel:IS_CONNECTED]->(to)
(ON CREATE) SET rel += row.properties
""".format(relations=relations)
session.run(query, relations=relations)
那么无论如何我可以通过使用批处理来添加关系吗?