我正在尝试检查两个节点之间是否存在关系,但是我收到了这个错误:
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)
答案 0 :(得分:0)
在代码中:
src = Node(src_type, internal_id=int(src_id))
dst = Node(dst_type, internal_id=int(dst_id))
src和dst是在本地创建的,但不绑定到数据库中的这些节点。 使用merge将本地节点绑定到数据库:
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”])