我試圖運行neomodel以下的Cypher查詢:的Neo4j,py2neo,Neomodel - Cypher支架最短路徑給錯誤 - 類型錯誤: 'NotImplementedType' 對象不是可調用
MATCH (b1:Bal { text:'flame' }), (b2:Bal { text:'candle' }),
p = shortestPath((b1)-[*..15]-(b2))
RETURN p
它通過對Neo4j的偉大工程服務器控制檯。它返回兩個連接關係的3個節點。然而,當我嘗試在Python以下幾點:
# Py2Neo version of cypher query in python
from py2neo import neo4j
graph_db = neo4j.GraphDatabaseService()
shortest_path_text = "MATCH (b1:Bal { text:'flame' }), (b2:Bal { text:'candle' }), p = shortestPath((b1)-[*..15]-(b2)) RETURN p"
results = neo4j.CypherQuery(graph_db, shortest_path_text).execute()
或
# neomodel version of cypher query in python
from neomodel import db
shortest_path_text = "MATCH (b1:Bal { text:'flame' }), (b2:Bal { text:'candle' }), p = shortestPath((b1)-[*..15]-(b2)) RETURN p"
results, meta = db.cypher_query(shortest_path_text)
均可以得到以下錯誤:
/Library/Python/2.7/site-packages/neomodel-1.0.1-py2.7.egg/neomodel/util.py in _hydrated(data)
73 elif obj_type == 'relationship':
74 return Rel(data)
---> 75 raise NotImplemented("Don't know how to inflate: " + repr(data))
76 elif neo4j.is_collection(data):
77 return type(data)([_hydrated(datum) for datum in data])
TypeError: 'NotImplementedType' object is not callable
這是有道理的考慮neomodel基於py2neo。
主要問題是如何讓shortestPath查詢通過其中任何一個工作? python中有更好的方法嗎?或者是密碼的最佳方式呢?
編輯:
我也試過以下從here給出了同樣的錯誤。
graph_db = neo4j.GraphDatabaseService()
query_string = "START beginning=node(1), end=node(4) \
MATCH p = shortestPath(beginning-[*..500]-end) \
RETURN p"
result = neo4j.CypherQuery(graph_db, query_string).execute()
for r in result:
print type(r) # r is a py2neo.util.Record object
print type(r.p) # p is a py2neo.neo4j.Path object
謝謝你Nigel。你能發佈你的代碼示例嗎?我很好奇如何在python中運行原始py2neo密碼查詢正如我以爲這是我在上面做的.. – raschwab 2014-10-03 02:54:18