简体   繁体   中英

How could I write a traversal query in neo4j (gremlin/cypher either one)?

Perferbly gremlin, but either one will do;

I am storing nodes in a database that form tree like structures. example: /dir/inside_dir/alaskan-natives/story1

Nodes are attached with a relationship called HAS_CHILD_NODE (if it would be more efficient to add properties to each relationship to speed up the query or make it more logical please inform me of this). Each node can only have one parent association. In one query - removing all looping from my application its self - how do I traverse down each path only to obtain specified ones until we have reached our end result.

Well assume I've already spliced at the '/' and now we have an array of hierarchal items we can attach to a query.

var array = ['dir', 'inside_dir', 'alaskan-natives', 'story1'];

Remember this must be a dynamic query allowing any amount of items to be traversed down the tree and consist of an ability to interchange hierarchal names. Try and optimize it please.

Just a simple tree to help in understanding; it is not related to my situation. 请查看此树示例

有关Neo4j的邮件列表, 请访问https://groups.google.com/group/neo4j/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM