Python Rexster使用OrientDB创建边缘错误

Python Rexster使用OrientDB创建边缘错误,python,orientdb,bulbs,rexster,Python,Orientdb,Bulbs,Rexster,我将python灯泡用于Rexster和OrientDB。我正在尝试创建边,但出现以下错误: >> g.edges.create(g.V[0], "aoeu", g.V[1]) Traceback (most recent call last): File "<input>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/bulbs/element.py", line

我将python灯泡用于Rexster和OrientDB。我正在尝试创建边,但出现以下错误:

>> g.edges.create(g.V[0], "aoeu", g.V[1])
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/bulbs/element.py", line 879, in create
    resp = self.client.create_edge(outV, label, inV, data, keys=_keys)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rexster/client.py", line 454, in create_edge
    return self.create_indexed_edge(outV,label,inV,data,index_name,keys=keys)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rexster/client.py", line 990, in create_indexed_edge
    resp = self.gremlin(script,params)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rexster/client.py", line 356, in gremlin
    return self.request.post(gremlin_path, params)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rest.py", line 131, in post
    return self.request(POST, path, params)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rest.py", line 186, in request
    return self.response_class(http_resp, self.config)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rexster/client.py", line 198, in __init__
    self.handle_response(response)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rexster/client.py", line 222, in handle_response
    response_handler(http_resp)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rest.py", line 50, in server_error
    raise SystemError(http_resp)
SystemError: ({'status': '500', 'transfer-encoding': 'chunked', 'server': 'grizzly/2.2.16', 'connection': 'close', 'date': 'Fri, 24 Jan 2014 19:49:10 GMT', 'access-control-allow-origin': '*', 'content-type':
 'application/json'}, '{"message":"","error":"javax.script.ScriptException: java.lang.ClassCastException: com.orientechnologies.orient.core.id.ORecordId cannot be cast to com.orientechnologies.orient.core.re
cord.ORecord","api":{"description":"evaluate an ad-hoc Gremlin script for a graph.","parameters":{"rexster.returnKeys":"an array of element property keys to return (default is to return all element propertie
s)","rexster.showTypes":"displays the properties of the elements with their native data type (default is false)","load":"a list of \'stored procedures\' to execute prior to the \'script\' (if \'script\' is n
ot specified then the last script in this argument will return the values","rexster.offset.end":"end index for a paged set of data to be returned","rexster.offset.start":"start index for a paged set of data
to be returned","params":"a map of parameters to bind to the script engine","language":"the gremlin language flavor to use (default to groovy)","script":"the Gremlin script to be evaluated"}},"success":false
}')
我的图形配置

    <graph>
        <graph-enabled>true</graph-enabled>
        <graph-name>orientdb</graph-name>
        <graph-type>orientgraph</graph-type>
        <graph-location>local:/tmp/orientdb</graph-location>
        <properties>
            <username>admin</username>
            <password>admin</password>
        </properties>
        <extensions>
            <allows>
                <allow>tp:gremlin</allow>
            </allows>
        </extensions>
    </graph>
我经常遇到的错误是什么?我该如何修复它

添加调试信息:

>>> from bulbs.rexster import DEBUG
>>> g.config.set_logger(DEBUG)
>>> g.edges.create(g.V[0], "a", g.V[1])
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST body: {"params": null, "script": "g.getVertices()"} 
POST body: {"params": null, "script": "g.getVertices()"} 
POST body: {"params": null, "script": "g.getVertices()"} 
POST body: {"params": null, "script": "g.getVertices()"} 
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST body: {"params": null, "script": "g.getVertices()"} 
POST body: {"params": null, "script": "g.getVertices()"} 
POST body: {"params": null, "script": "g.getVertices()"} 
POST body: {"params": null, "script": "g.getVertices()"} 
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST body: {"params": {"label_var": "label", "outV": "#9:0", "keys": null, "data": {}, "inV": "#9:1", "index_name": "edge", "label": "a"}, "script": "def createIndexedEdge = {\n    index = g.idx(index_name)\n    edge = g.addEdge(g.v(outV),g.v(inV),label)\n    for (entry in data.entrySet()) {\n      if (entry.value == null) continue;\n      edge.setProperty(entry.key,entry.value)\n      if (keys == null || keys.contains(entry.key))\n\tindex.put(entry.key,String.valueOf(entry.value),edge)\n    }\n    index.put(label_var,String.valueOf(label),edge)\n    return edge\n  }\n  def transaction = { final Closure closure ->\n    try {\n      results = closure();\n      g.commit();\n      return results; \n    } catch (e) {\n      g.rollback();\n      throw e;\n    }\n  }\n  return transaction(createIndexedEdge);"} 
POST body: {"params": {"label_var": "label", "outV": "#9:0", "keys": null, "data": {}, "inV": "#9:1", "index_name": "edge", "label": "a"}, "script": "def createIndexedEdge = {\n    index = g.idx(index_name)\n    edge = g.addEdge(g.v(outV),g.v(inV),label)\n    for (entry in data.entrySet()) {\n      if (entry.value == null) continue;\n      edge.setProperty(entry.key,entry.value)\n      if (keys == null || keys.contains(entry.key))\n\tindex.put(entry.key,String.valueOf(entry.value),edge)\n    }\n    index.put(label_var,String.valueOf(label),edge)\n    return edge\n  }\n  def transaction = { final Closure closure ->\n    try {\n      results = closure();\n      g.commit();\n      return results; \n    } catch (e) {\n      g.rollback();\n      throw e;\n    }\n  }\n  return transaction(createIndexedEdge);"} 
POST body: {"params": {"label_var": "label", "outV": "#9:0", "keys": null, "data": {}, "inV": "#9:1", "index_name": "edge", "label": "a"}, "script": "def createIndexedEdge = {\n    index = g.idx(index_name)\n    edge = g.addEdge(g.v(outV),g.v(inV),label)\n    for (entry in data.entrySet()) {\n      if (entry.value == null) continue;\n      edge.setProperty(entry.key,entry.value)\n      if (keys == null || keys.contains(entry.key))\n\tindex.put(entry.key,String.valueOf(entry.value),edge)\n    }\n    index.put(label_var,String.valueOf(label),edge)\n    return edge\n  }\n  def transaction = { final Closure closure ->\n    try {\n      results = closure();\n      g.commit();\n      return results; \n    } catch (e) {\n      g.rollback();\n      throw e;\n    }\n  }\n  return transaction(createIndexedEdge);"} 
POST body: {"params": {"label_var": "label", "outV": "#9:0", "keys": null, "data": {}, "inV": "#9:1", "index_name": "edge", "label": "a"}, "script": "def createIndexedEdge = {\n    index = g.idx(index_name)\n    edge = g.addEdge(g.v(outV),g.v(inV),label)\n    for (entry in data.entrySet()) {\n      if (entry.value == null) continue;\n      edge.setProperty(entry.key,entry.value)\n      if (keys == null || keys.contains(entry.key))\n\tindex.put(entry.key,String.valueOf(entry.value),edge)\n    }\n    index.put(label_var,String.valueOf(label),edge)\n    return edge\n  }\n  def transaction = { final Closure closure ->\n    try {\n      results = closure();\n      g.commit();\n      return results; \n    } catch (e) {\n      g.rollback();\n      throw e;\n    }\n  }\n  return transaction(createIndexedEdge);"} 
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/bulbs/element.py", line 879, in create
    resp = self.client.create_edge(outV, label, inV, data, keys=_keys)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rexster/client.py", line 454, in create_edge
    return self.create_indexed_edge(outV,label,inV,data,index_name,keys=keys)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rexster/client.py", line 990, in create_indexed_edge
    resp = self.gremlin(script,params)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rexster/client.py", line 356, in gremlin
    return self.request.post(gremlin_path, params)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rest.py", line 131, in post
    return self.request(POST, path, params)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rest.py", line 186, in request
    return self.response_class(http_resp, self.config)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rexster/client.py", line 198, in __init__
    self.handle_response(response)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rexster/client.py", line 222, in handle_response
    response_handler(http_resp)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rest.py", line 50, in server_error
    raise SystemError(http_resp)
SystemError: ({'status': '500', 'transfer-encoding': 'chunked', 'server': 'grizzly/2.2.16', 'connection': 'close', 'date': 'Mon, 27 Jan 2014 18:33:00 GMT', 'access-control-allow-origin': '*', 'content-type': 'application/json'}, '{"message":"","error":"javax.script.ScriptException: java.lang.ClassCastException: com.orientechnologies.orient.core.id.ORecordId cannot be cast to com.orientechnologies.orient.core.record.ORecord","api":{"description":"evaluate an ad-hoc Gremlin script for a graph.","parameters":{"rexster.returnKeys":"an array of element property keys to return (default is to return all element properties)","rexster.showTypes":"displays the properties of the elements with their native data type (default is false)","load":"a list of \'stored procedures\' to execute prior to the \'script\' (if \'script\' is not specified then the last script in this argument will return the values","rexster.offset.end":"end index for a paged set of data to be returned","rexster.offset.start":"start index for a paged set of data to be returned","params":"a map of parameters to bind to the script engine","language":"the gremlin language flavor to use (default to groovy)","script":"the Gremlin script to be evaluated"}},"success":false}')

如果在Bulls中启用调试,则可以看到命令和参数Bulls正在发送到Rexster:

>>>从bulls.rexster导入图中,调试 >>>g=图 >>>g.config.set_loggerDEBUG >>>g.edges.createg.V[0],aoeu,g.V[1] 这里是g.边。创建

def createself、outV、label、inV、_data=None、_keys=None、**kwds: 在数据库中创建边并返回它。 :param outV:传出顶点。 :键入outV:Vertex或int :param label:边的标签。 :类型标签:str :param inV:传入顶点。 :type inV:Vertex或int :param_data:可选属性数据dict。 :type\u数据:dict :param kwds:可选的属性数据关键字对。 :类型kwds:dict :rtype:Edge 断言标签不是无 数据=构建数据,kwds 输出,输入=强制输出输出,输入 resp=self.client.create\u edgeoutV、标签、库存、数据、密钥=\u密钥 返回initialize_elementself.client,resp.resp.result …正在调用低级client.create_edge方法

边代理 def create_edgeself,outV,label,inV,data={},keys=None: 创建边并返回响应。 :param outV:传出顶点ID。 :键入outV:int :参数标签:边缘标签。 :类型标签:str :param inV:传入顶点ID。 :type inV:int :param data:属性数据。 :类型数据:dict或None :rtype:RexsterResponse 如果keys或self.config.autoindex为True: index\u name=self.config.edge\u index 返回self.create\u index\u edgeoutV、label、inV、data、index\u name、keys=keys 数据=自身。\u删除\u空值\u值数据 边缘数据=dict\U outV=outV,\U label=label,\U inV=inV data.updatedge\u数据 返回self.request.postdedge\u路径,数据 …如果您将config.autoindex设置为True(默认设置),那么它最终会调用client.create\u index\u edge

def create_index_edgeself,outV,label,inV,data,index_name,keys=None: 创建边,为其编制索引,并返回响应。 :param outV:传出顶点ID。 :键入outV:int :参数标签:边缘标签。 :类型标签:str :param inV:传入顶点ID。 :type inV:int :param data:属性数据。 :类型数据:dict :param index_name:索引的名称。 :类型索引\u名称:str :param keys:要索引的属性键。默认为“无”,对所有属性进行索引。 :键入键:列表 :rtype:RexsterResponse 数据=自身。\u删除\u空值\u值数据 edge_参数=dictoutV=outV,label=label,inV=inV,label_var=self.config.label_var params=dictdata=data,index\u name=index\u name,keys=keys params.updateedge_params script=self.scripts.getcreate\u index\u edge resp=self.gremlinscript,参数 resp.results=resp.one 返回响应 …注意client.create_index_edge Python方法将create_index_edge Gremlin脚本的主体发送到Rexster

//来自灯泡/Rexster gremlin.groovy def create_indexed_edgeoutV、标签、库存、数据、索引名称、键、标签变量{ def createIndexedge={ 索引=g.idxindex\u名称 边缘=g.addedge.voutV,g.vinV,标签 用于data.entrySet中的条目{ 如果entry.value==null,则继续; edge.setPropertyentry.key,entry.value 如果keys==null | | keys.containsentry.key index.putentry.key,String.valueOfentry.value,edge } index.putlabel_var,String.valueOflabel,edge 返回边 } def事务={final Closure-> 试一试{ 结果=闭合; g、 承诺; 返回结果; }抓住e{ g、 回滚; 投掷e; } } 返回TransactionCreateIndexedge; }
在OrientDB 1.7中修复,请参阅以获取更多信息。

每次实例化新的配置对象时,都会多次添加日志处理程序-我刚刚向GitHub和PyPi推送了一个更新以防止重复输出。共有3个命令,因为您调用了两次g.V,调用了一次g.edges.create。供将来参考,请参阅发布到GitHub的@Derek对该问题的评论
>>> from bulbs.rexster import DEBUG
>>> g.config.set_logger(DEBUG)
>>> g.edges.create(g.V[0], "a", g.V[1])
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST body: {"params": null, "script": "g.getVertices()"} 
POST body: {"params": null, "script": "g.getVertices()"} 
POST body: {"params": null, "script": "g.getVertices()"} 
POST body: {"params": null, "script": "g.getVertices()"} 
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST body: {"params": null, "script": "g.getVertices()"} 
POST body: {"params": null, "script": "g.getVertices()"} 
POST body: {"params": null, "script": "g.getVertices()"} 
POST body: {"params": null, "script": "g.getVertices()"} 
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST url:  http://localhost:8182/graphs/orientdb/tp/gremlin  
POST body: {"params": {"label_var": "label", "outV": "#9:0", "keys": null, "data": {}, "inV": "#9:1", "index_name": "edge", "label": "a"}, "script": "def createIndexedEdge = {\n    index = g.idx(index_name)\n    edge = g.addEdge(g.v(outV),g.v(inV),label)\n    for (entry in data.entrySet()) {\n      if (entry.value == null) continue;\n      edge.setProperty(entry.key,entry.value)\n      if (keys == null || keys.contains(entry.key))\n\tindex.put(entry.key,String.valueOf(entry.value),edge)\n    }\n    index.put(label_var,String.valueOf(label),edge)\n    return edge\n  }\n  def transaction = { final Closure closure ->\n    try {\n      results = closure();\n      g.commit();\n      return results; \n    } catch (e) {\n      g.rollback();\n      throw e;\n    }\n  }\n  return transaction(createIndexedEdge);"} 
POST body: {"params": {"label_var": "label", "outV": "#9:0", "keys": null, "data": {}, "inV": "#9:1", "index_name": "edge", "label": "a"}, "script": "def createIndexedEdge = {\n    index = g.idx(index_name)\n    edge = g.addEdge(g.v(outV),g.v(inV),label)\n    for (entry in data.entrySet()) {\n      if (entry.value == null) continue;\n      edge.setProperty(entry.key,entry.value)\n      if (keys == null || keys.contains(entry.key))\n\tindex.put(entry.key,String.valueOf(entry.value),edge)\n    }\n    index.put(label_var,String.valueOf(label),edge)\n    return edge\n  }\n  def transaction = { final Closure closure ->\n    try {\n      results = closure();\n      g.commit();\n      return results; \n    } catch (e) {\n      g.rollback();\n      throw e;\n    }\n  }\n  return transaction(createIndexedEdge);"} 
POST body: {"params": {"label_var": "label", "outV": "#9:0", "keys": null, "data": {}, "inV": "#9:1", "index_name": "edge", "label": "a"}, "script": "def createIndexedEdge = {\n    index = g.idx(index_name)\n    edge = g.addEdge(g.v(outV),g.v(inV),label)\n    for (entry in data.entrySet()) {\n      if (entry.value == null) continue;\n      edge.setProperty(entry.key,entry.value)\n      if (keys == null || keys.contains(entry.key))\n\tindex.put(entry.key,String.valueOf(entry.value),edge)\n    }\n    index.put(label_var,String.valueOf(label),edge)\n    return edge\n  }\n  def transaction = { final Closure closure ->\n    try {\n      results = closure();\n      g.commit();\n      return results; \n    } catch (e) {\n      g.rollback();\n      throw e;\n    }\n  }\n  return transaction(createIndexedEdge);"} 
POST body: {"params": {"label_var": "label", "outV": "#9:0", "keys": null, "data": {}, "inV": "#9:1", "index_name": "edge", "label": "a"}, "script": "def createIndexedEdge = {\n    index = g.idx(index_name)\n    edge = g.addEdge(g.v(outV),g.v(inV),label)\n    for (entry in data.entrySet()) {\n      if (entry.value == null) continue;\n      edge.setProperty(entry.key,entry.value)\n      if (keys == null || keys.contains(entry.key))\n\tindex.put(entry.key,String.valueOf(entry.value),edge)\n    }\n    index.put(label_var,String.valueOf(label),edge)\n    return edge\n  }\n  def transaction = { final Closure closure ->\n    try {\n      results = closure();\n      g.commit();\n      return results; \n    } catch (e) {\n      g.rollback();\n      throw e;\n    }\n  }\n  return transaction(createIndexedEdge);"} 
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/bulbs/element.py", line 879, in create
    resp = self.client.create_edge(outV, label, inV, data, keys=_keys)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rexster/client.py", line 454, in create_edge
    return self.create_indexed_edge(outV,label,inV,data,index_name,keys=keys)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rexster/client.py", line 990, in create_indexed_edge
    resp = self.gremlin(script,params)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rexster/client.py", line 356, in gremlin
    return self.request.post(gremlin_path, params)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rest.py", line 131, in post
    return self.request(POST, path, params)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rest.py", line 186, in request
    return self.response_class(http_resp, self.config)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rexster/client.py", line 198, in __init__
    self.handle_response(response)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rexster/client.py", line 222, in handle_response
    response_handler(http_resp)
  File "/usr/local/lib/python2.7/dist-packages/bulbs/rest.py", line 50, in server_error
    raise SystemError(http_resp)
SystemError: ({'status': '500', 'transfer-encoding': 'chunked', 'server': 'grizzly/2.2.16', 'connection': 'close', 'date': 'Mon, 27 Jan 2014 18:33:00 GMT', 'access-control-allow-origin': '*', 'content-type': 'application/json'}, '{"message":"","error":"javax.script.ScriptException: java.lang.ClassCastException: com.orientechnologies.orient.core.id.ORecordId cannot be cast to com.orientechnologies.orient.core.record.ORecord","api":{"description":"evaluate an ad-hoc Gremlin script for a graph.","parameters":{"rexster.returnKeys":"an array of element property keys to return (default is to return all element properties)","rexster.showTypes":"displays the properties of the elements with their native data type (default is false)","load":"a list of \'stored procedures\' to execute prior to the \'script\' (if \'script\' is not specified then the last script in this argument will return the values","rexster.offset.end":"end index for a paged set of data to be returned","rexster.offset.start":"start index for a paged set of data to be returned","params":"a map of parameters to bind to the script engine","language":"the gremlin language flavor to use (default to groovy)","script":"the Gremlin script to be evaluated"}},"success":false}')