[英]ArangoDB - Collection not found error though the collection is created
我在兩個文檔之間創建一條邊“ has_taken”,如下所示:
sin_graph.createEdge("has_taken", userDoc._id, tripDoc._id, edgeAttributes={})
我收到以下錯誤:
File "/Library/Python/2.7/site-packages/pyArango/graph.py", line 135, in createEdge raise CreationError("Unable to create edge, %s" % r.json()["errorMessage"], data) CreationError: Unable to create edge, collection not found. Errors: {u'code': 404, u'errorNum': 1203, u'errorMessage': u'collection not found', u'error': True}
存在名稱為“ has_taken”的集合,但是我遇到了以上錯誤。
我已經將社交圖示例轉換為pyArango。 它說明了使用它維護圖形數據時要做的事情的順序:
#!/usr/bin/python
import sys
from pyArango.connection import *
from pyArango.graph import *
from pyArango.collection import *
class Social(object):
class male(Collection) :
_fields = {
"name" : Field()
}
class female(Collection) :
_fields = {
"name" : Field()
}
class relation(Edges) :
_fields = {
"number" : Field()
}
class social(Graph) :
_edgeDefinitions = (EdgeDefinition ('relation',
fromCollections = ["female", "male"],
toCollections = ["female", "male"]),)
_orphanedCollections = []
def __init__(self):
self.conn = Connection(username="root", password="")
self.db = self.conn["_system"]
if self.db.hasGraph('social'):
raise Exception("The social graph was already provisioned! remove it first")
self.female = self.db.createCollection("female")
self.male = self.db.createCollection("male")
self.relation = self.db.createCollection("relation")
g = self.db.createGraph("social")
a = g.createVertex('female', {"name": 'Alice', "_key": 'alice'});
b = g.createVertex('male', {"name": 'Bob', "_key": 'bob'});
c = g.createVertex('male', {"name": 'Charly', "_key": 'charly'});
d = g.createVertex('female', {"name": 'Diana', "_key": 'diana'});
a.save()
b.save()
c.save()
d.save()
g.link('relation', a, b, {"type": 'married', "_key": 'aliceAndBob'})
g.link('relation', a, c, {"type": 'friend', "_key": 'aliceAndCharly'})
g.link('relation', c, d, {"type": 'married', "_key": 'charlyAndDiana'})
g.link('relation', b, d, {"type": 'friend', "_key": 'bobAndDiana'})
Social()
我認為這可能是因為您收集了Collection類型而不是Edge類型的集合(哈哈,令人困惑,我知道。)
但是在進行名為“ has_taken”的集合時,
db.createCollection(className="Collection", name="has_taken")
嘗試
db.createCollection(className="Edges", name="has_taken")
我在閱讀此頁面時注意到。 (單擊該鏈接時,請查看屏幕的最上方。該功能及其說明就在此處,並且提到了這一區別。)
createCollection(className='Collection', waitForSync=False, **colArgs)[source]
創建一個集合並返回它。 ClassName繼承自Collection或Egdes的類的名稱,也可以將其設置為'Collection'或'Edges',以創建文檔或Edges的無類型集合。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.