2016-12-28 65 views
0

我創建兩個文件之間的邊緣「has_taken」如下:ArangoDB - 集合未找到錯誤,雖然集合是創建

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」的集合存在,但我收到上述錯誤。

+0

你能寫更多的細節嗎?你從哪裏得到'sin_graph'? –

+0

我用下面的命令我圖 sin_graph = db.graphs [「Graph_name」] 我創建使用arangoDB –

+0

的GUI你確定你使用了正確的DB這個圖?而不是_system> –

回答

0

我想這可能是因爲你做Collection類型的集合,而不是嘉匯

但一種名爲 「has_taken」 集合的時候,而不是

db.createCollection(className="Collection", name="has_taken") 

嘗試

db.createCollection(className="Edges", name="has_taken") 

我注意到當我在閱讀this頁面。 (當你點擊那個鏈接時,看看屏幕的最上面,功能和描述就在那裏,它提到了這個區別。)

createCollection(className='Collection', waitForSync=False, **colArgs)[source] 

Creates a collection and returns it. ClassName the name of a class inheriting from Collection or Egdes, it can also be set to ‘Collection’ or ‘Edges’ in order to create untyped collections of documents or edges.

0

我已經將social graph example的例子轉換成pyArango;它ilustrates事物的順序保持與它的圖形數據時要做到:(哈哈,混亂的,我知道)

#!/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()