Py2neo - ValueError: Primary label and primary key are required for MERGE operation

时间:2019-03-19 14:52:57

标签: python neo4j py2neo

I am new to py2neo and trying to understand the merge operation with respect to joining with other type of nodes with different primary key. ex: I followed the below link https://py2neo.org/v4/database.html

    graphdb = Graph(scheme="bolt", host="localhost", port=7687, secure=True, auth=(userName, userPass))

a = Node("Person", name="Alice", age=33)
b = Node("Person", name="Bob", age=44)
KNOWS = Relationship.type("KNOWS")
graphdb.merge(KNOWS(a, b), "Person", "name")

c = Node("Company", name="ACME")
c.__primarylabel__ = "Company"
c.__primarykey__ = "name"
WORKS_FOR = Relationship.type("WORKS_FOR")
graphdb.merge(WORKS_FOR(a, c) | WORKS_FOR(b, c))

everything is fine until here... next

Expected: I want to find person and add one more relationship with person node

a1 = graphdb.nodes.match("Person", age=33)
print(a1)

d = Node("Company", name="OLDCOM")
d.__primarylabel__ = "Company"
d.__primarykey__ = "name"
WORKED_FOR = Relationship.type("WORKED_FOR")
graphdb.merge(WORKED_FOR(a1, d))

ERROR: raise ValueError("Primary label and primary key are required for MERGE operation") ValueError: Primary label and primary key are required for MERGE operation

There is no common primarykey or label between these nodes as they are of different types.

0 个答案:

没有答案