简体   繁体   English

ArangoDB-尽管创建了集合,但找不到集合错误

[英]ArangoDB - Collection not found error though the collection is created

I am creating an edge "has_taken" between two documents as follows: 我在两个文档之间创建一条边“ has_taken”,如下所示:

sin_graph.createEdge("has_taken", userDoc._id, tripDoc._id, edgeAttributes={})

And I am getting the following error: 我收到以下错误:

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}

The collection with the name "has_taken" is present and yet I am getting the above error. 存在名称为“ has_taken”的集合,但是我遇到了以上错误。

I have transpiled the social graph example example to pyArango; 我已经将社交图示例转换为pyArango。 It ilustrates the sequence of things to do when maintaining graph data with it: 它说明了使用它维护图形数据时要做的事情的顺序:

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

I think it may be because you made a collection of type Collection and not of type Edge (haha, confusing, I know.) 我认为这可能是因为您收集了Collection类型而不是Edge类型的集合(哈哈,令人困惑,我知道。)

But when making the collection called "has_taken", instead of 但是在进行名为“ has_taken”的集合时,

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

try 尝试

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

I noticed that when I was reading this page. 我在阅读页面时注意到。 (Look at the very top of your screen when you click that link. The function and its description is right up there and it mentions this difference.) (单击该链接时,请查看屏幕的最上方。该功能及其说明就在此处,并且提到了这一区别。)

 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. ClassName继承自Collection或Egdes的类的名称,也可以将其设置为'Collection'或'Edges',以创建文档或Edges的无类型集合。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM