[英]Update property relation with py2neo neo4j
我正在嘗試檢查兩個節點之間是否存在關系,但出現此錯誤:
raise TypeError("Nodes for relationship match end points must be bound") TypeError: Nodes for relationship match end points must be bound
在我的代碼下面:
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)
在代碼中:
src = Node(src_type, internal_id=int(src_id))
dst = Node(dst_type, internal_id=int(dst_id))
src和dst在本地創建,但未綁定到數據庫中的這些節點。 通過合並將本地節點綁定到數據庫:
db_src = graph.merge(src)
db_dst = graph.merge(dst)
然后匹配應該起作用:
for elem in graph.match(db_src, "VOTED", db_dst)
(請注意elem.properties [“ vote”]不起作用,應該有一些鏈接elem.start_node()[“ vote”]或elem.end_node()[“ vote”])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.