neo4j - Hierarchical Cypher query with literal result -


itemprop = "text">

My object structure looks like this: Containers are in the form of a root nodes, which contain subcontractors in each sub-container There are also sub-texts. To indicate in the cipher MATCH:

(Container) - [: HAS_SUBCONTAINER] -> (Subject) - [: HAS_TASK] -> (task) - [: HAS_TASK] -> (subtasks) )

I want to write a query that gives the literal representation of Jason to this Hirachi:

  {name: 'maine', subclaimer: [ {Name: good luck}, work: [{name: 'parent1', child: [{name: 'child1'})}]}]}  

whether such a cipher Is there a way to do a question? I found a level hierarchy solution:

  MATCH (cnt: container {name: 'main'}) - [: HAS_SUBCONTAINER] - & gt; (Subcnt) returns {name: cnt.name, subcontent: extract (subsy is assembled (subcnt) | {name: subc.name})}  

but for a more complex case Can not tell any idea how to do it?

By looking at the depth of your matching pattern, you are nesting (consignor) in a series - [: HAS_SUBCONTAINER] - & gt; (Epitomize) - [: HAS_TASK] - & gt; (Work) - [: HAS_TASK] - & gt; Work with containers such as subtasks (subtitles) with containers, subcons, work ({name: subtask.name}) containers, subcounts, assembled ({name: task.name, children: subtasks}) ({name: Subcontrant names, tasks: actions}} as a sub-return {name: container.name, subcontanters: subcountains} as a result

if there are subtask options (@gim -bird questions), then you will need an optional match and a case statement:

  MATCH (container) - [: HAS_SUBCONTAINER] - & gt; (Subcong) - [: HAS_TASK] - & gt; (Work) Alternate matching (work) - [: HAS_TASK] - & gt; Collect the container, subconsum, (subtasks) with work (case subtasks when null then nail alease {name: subtask.name} END) to collect tasks with container, lesson container ({name: subcont.name, tasks: Collects} {name: container.name, subcontainers: subconts} AS subconts (eg: name: work.name, children: subtasks}) results  

Comments