The question was already asked on stackoverflow, but I'd like to put it
here also.
My object structure looks like the following: there are Containers as a
root nodes, which have subcontainers. Each subcontainer has tasks, which
also have subtasks. To illustracte thisstructure in Cypher MATCH:
(container)-[:HAS_SUBCONTAINER]->(subcont)-[:HAS_TASK]->(task)-[:HAS_TASK]->(subtask)
I want to write a query which returns JSON literal representation for this
hierachy:
{
name: 'Main',
subcontainers: [
{
name: 'Subcont',
tasks: [
{
name: 'parent1',
children: [
{
name: 'child1'
}
]
}
]
}
]
}
Is there a way to do this in Cypher with one query? I found solution for
one level hierarchy:
MATCH (cnt:Container {name: 'Main'})-[:HAS_SUBCONTAINER]->(subcnt)
RETURN { name: cnt.name, subcontainers: EXTRACT(subc IN collect(subcnt)|{name:
subc.name})}
But can't fugure out how to do it for more complex case. Any ideas how to
solve this?
--
You received this message because you are subscribed to the Google Groups
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.