2016-12-28 6 views
0

を作成しているが、エラーが見つかりません次のように私は2つの文書間のエッジ「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

私は、次のコマンドによって、私のグラフを得た私はarangoDB –

+0

のGUIを使用して、このグラフを作成している sin_graph = db.graphs [「Graph_name」] はあなたが正しいDBを使用していますか?とは_system> –

答えて

0

私はあなたがタイプのエッジの種類コレクションとないのコレクションを作ったので、それがかもしれないと思う

(笑、私が知っている、混乱します。)

しかし、その代わりに

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

の、 "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()