1. 程式人生 > >ValueError: Node ({location: 'shanghai', name: 'mike'}) does not belong to this graph

ValueError: Node ({location: 'shanghai', name: 'mike'}) does not belong to this graph

>>> [i for i in g.relationships.match((g.nodes.match('boy',name='mike'),) )]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in <listcomp>
File "/home/hzc/anaconda3/lib/python3.6/site-packages/py2neo/matching.py", line 262, in __iter__
query, parameters = self._query_and_parameters()
File "/home/hzc/anaconda3/lib/python3.6/site-packages/py2neo/matching.py", line 307, in _query_and_parameters
verify_node(start_node)
File "/home/hzc/anaconda3/lib/python3.6/site-packages/py2neo/matching.py", line 284, in verify_node
raise ValueError("Node %r does not belong to this graph" % n)
ValueError: Node ({location: 'shanghai', name: 'mike'}) does not belong to this graph

此時g.relationships.match()裡面不是node,需要加個first(),得到node才可以。

>>> [i for i in g.relationships.match((g.nodes.match('boy',name='mike').first(),) )]
[(mike)-[:LOVE {}]->(alice)]</textarea>