1

我通过灯泡使用 neo4j 的 REST API,并尝试通过密码删除一个节点以及所有关联的边缘,如下所示:

from bulbs.neo4jserver import Graph as Neo4jGraph
db = Graph()

query = '''START d=node(57)
           MATCH d-[r]-()
           DELETE d,r
        '''
t = db.cypher.execute(query)

dbneo4j-database-Handler 在哪里)。

......它似乎并不像那样工作。一个长的错误报告如下:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/tobias/Esk/Dev/liquidDemocracyLight/venv/local/lib/python2.7/site-packages/bulbs/neo4jserver/cypher.py", line 31, in execute
    return self.client.cypher(query, params)
  File "/home/tobias/Esk/Dev/liquidDemocracyLight/venv/local/lib/python2.7/site-packages/bulbs/neo4jserver/client.py", line 403, in cypher
    resp = self.request.post(path, params)
  File "/home/tobias/Esk/Dev/liquidDemocracyLight/venv/local/lib/python2.7/site-packages/bulbs/rest.py", line 126, in post
    return self.request(POST, path, params)
  File "/home/tobias/Esk/Dev/liquidDemocracyLight/venv/local/lib/python2.7/site-packages/bulbs/rest.py", line 181, in request
    return self.response_class(http_resp, self.config)
  File "/home/tobias/Esk/Dev/liquidDemocracyLight/venv/local/lib/python2.7/site-packages/bulbs/neo4jserver/client.py", line 217, in __init__
    self.handle_response(response)
  File "/home/tobias/Esk/Dev/liquidDemocracyLight/venv/local/lib/python2.7/site-packages/bulbs/neo4jserver/client.py", line 249, in handle_response
    response_handler(response)
  File "/home/tobias/Esk/Dev/liquidDemocracyLight/venv/local/lib/python2.7/site-packages/bulbs/rest.py", line 36, in bad_request
    raise ValueError(http_resp)
ValueError: ({'status': '400', 'content-length': '3989', 'content-encoding': 'UTF-8', 'server': 'Jetty(6.1.25)', 'access-control-allow-origin': '*', 'content-type': 'application/json'}, '{\n  "message" : "expected return clause\\n\\"           DELETE d,r\\"\\n            ^",\n  "exception" : "org.neo4j.server.rest.repr.BadInputException: expected return clause\\n\\"           DELETE d,r\\"\\n 

难道我做错了什么?是否可以通过灯泡通过密码查询删除节点?

4

2 回答 2

1

看起来您正在运行旧版本的 Neo4j?DELETE仅在 1.8 中添加。

于 2012-11-22T14:51:31.547 回答
1

Bulbs 具有用于删除节点/顶点及其所有关系的内置方法。

>>> from bulbs.neo4jserver import Graph
>>> g = Graph()
>>> g.vertices.delete(57)

请参阅http://bulbflow.com/docs/api/bulbs/element/#vertex-proxy

为此,Bulbsdelete()方法在后台使用了 Gremlin 脚本,因为 Neo4j 服务器不提供单个端点来删除顶点及其所有事件边。

代码如下所示:

请注意,上面的 Gremlin 脚本使用 Blueprints removeVertex() 方法(内置于 Neo4j Server 中),因为它会为您删除所有事件边缘。

https://github.com/tinkerpop/blueprints/blob/master/blueprints-neo4j-graph/src/main/java/com/tinkerpop/blueprints/impls/neo4j/Neo4jGraph.java#L409

于 2012-11-23T10:56:24.517 回答