2012-11-22 66 views
1

我經由燈泡使用的Neo4j的REST API,我試圖與所有相關的邊經由暗號一起刪除節點是這樣的:燈泡Neo4j的嵌入,並刪除在暗號

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) 

(其中db是Neo4j的-database-處理程序)。

...它似乎並沒有像那樣工作。長的錯誤報告如下:

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 

我做錯了什麼?難道通過燈泡通過cypher-querys刪除節點是不可能的?

回答

1

它看起來像你運行的是舊版本的Neo4j? DELETE僅在1.8中添加。

+0

也不確定在其關係之前刪除節點是不會解析的。 – ulkas

+0

只要它們在相同的刪除語句中,它就會。 –

+0

你是對的 - 我運行版本1.7 ... – phynfo

1

燈泡有一個內置的方法來刪除節點/頂點及其所有關係。

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

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

要做到這一點,燈泡delete()方法使用精怪腳本的引擎蓋下,因爲Neo4j的服務器不提供單個端點與它的所有關聯邊沿着刪除一個頂點。

下面的代碼是什麼樣子:

通知中的上述小鬼腳本使用藍圖removeVertex()方法(它是內置Neo4j服務器),因爲它負責爲您移除所有事件邊緣。

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