I modeled a directional tree structure using the Neo4J chart database. So, I have something like this: http://ouwarovite.net/YAPC/220px-Binary_tree.svg.png (optional binary)
My database users can add child nodes to existing nodes as they wish, so the tree height and degree of single nodes are unknown.
Now I want to query my tree as follows: Starting with node x, give me all the leaves that are descendants of leave x.
Is this type of request executed with Gremlin or Cypher, and if so, how can I do this to achieve maximum performance? (I did not find the ability to execute queries on "common" trees, because you always need to specify the maximum depth)
I know that this is possible using the REST / JSON framework and the JAVA API as follows:
POST /db/data/node/51/traverse/node { "return_filter" : { "body" : "position.endNode().hasProperty('leave')" , "language" : "javascript" }, "relationships" : [ { "type" : "_default", "direction" : "out" } ] , "prune_evaluator" : { "name" : "none" , "language" : "builtin" } }
(my leaves have a βleaveβ property, my ribs have no type β so _default)
Is there an easier / better way to do this, possibly with better performance?
source share