[英]Update property relation with py2neo neo4j
I'm trying to check if a relation between two nodes exists but i get this error: 我正在尝试检查两个节点之间是否存在关系,但出现此错误:
raise TypeError("Nodes for relationship match end points must be bound") TypeError: Nodes for relationship match end points must be bound
below my code: 在我的代码下面:
graph = Graph(user='neo4j')
src = Node(src_type, internal_id=int(src_id))
dst = Node(dst_type, internal_id=int(dst_id))
src_voted_dst = Relationship(src, "VOTED", dst)
for elem in graph.match(start_node=src, rel_type="VOTED", end_node=dst, bidirectional=True):
elem.properties["vote"] = elem.properties["vote"] + 1
elem.push()
break
else:
src_voted_dst.properties["vote"] = 1
graph.merge(src_voted_dst)
In the code: 在代码中:
src = Node(src_type, internal_id=int(src_id))
dst = Node(dst_type, internal_id=int(dst_id))
src and dst are created locally, but not bound to these nodes in the database. src和dst在本地创建,但未绑定到数据库中的这些节点。 Bind the local nodes to the database with merge: 通过合并将本地节点绑定到数据库:
db_src = graph.merge(src)
db_dst = graph.merge(dst)
Then match should then work: 然后匹配应该起作用:
for elem in graph.match(db_src, "VOTED", db_dst)
(note that elem.properties["vote"] will not work, there should be something link elem.start_node()["vote"] or elem.end_node()["vote"]) (请注意elem.properties [“ vote”]不起作用,应该有一些链接elem.start_node()[“ vote”]或elem.end_node()[“ vote”])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.