Friday 15 February 2013

neo4j - How to delete followed nodes by length variable -


I have tree structure, like node (8) has two children node (13) and node (14). When I remove node (8) by cypher, how can I remove all children?

I write ciphers like this: "Start R = node (8) match R - [: children * 0 ..] -> D match with D - D [x] - () Delete D, X "

This should work, but in fact it only removes the node (8) and get some error, I think it is actually trying to delete a collection like this. Used to be.

  • --- d ------------------- r
  • node (8) ----- ----- Reel (16)
  • Node (8) ---------- Reel (17)
  • Node (9) ----- ----- Reel (16)
  • Node (10) --------- Relay (17)

    and cyhper first node (8 ), Another attempt to remove node (8) and gets an error because it no longer exists.

    This is the wired reason I write ciphers in this way: "Start R = node (8) Match R - [: Kids * 0 ..] -> D Returns D" This Return:

  • Node (8)
  • node (8)
  • node (9)
  • Node (10)

    And that's right. But as we know, I can not remove them with a relationship, so I need to write a cyber with "Together":

    "Start R = node (8) Match R - [: Children * 0 ..] -> D match with D - [X] - () Returns D, X "

    And it gets the wrong result again.

    • - - D ------------------- r
    • Node (8) ------ ---- Reel (16)
    • Node (8) ---------- Reel (17)
    • Node (9) ------ ---- Reel (16)
    • Node (10) --------- Rel (17)

      Can someone help me ? It really is sad I actually like neo4j, but I think the "delete" part is so hard. Why not just use "Force Delete" and NEO 4J to remove relationships as yourself:

      "Start R = Node (8) Match R - [: Kids * 0 ..] - & gt; de force DELETE d "

      And why can not BTW use" delete "part separately?

      There was a bug in the previous neo4j version - I do not remember which version of which you use is being done? You should be able to do this type of query without any error about the current node.

      I also believe that this syntax should be easy. In this way I've got to work.

        start n = node (8) // start with node which matches you n- [r: children * 0 ..] - & gt; ; M, n- [any other]? - () // Find out to remove your pattern, and remove any other relationship from N (inbound / non-children) (in x: delete x) // remove all, delete relationships for children , N, otherwise; // Delete nodes and other relationships    

No comments:

Post a Comment