How to query to get n level depth nodes in neo4j
I want to write a query that will fetch the ciphers(nodes) along with its child nodes to the n-level.
e.g. if any child is having 1 child node and that child node is also having a sub child and that sub child node is also having a sub child node and it continues to the n times. then I want to fetch a result like
{
P: {
// parent node info,
child: [
// data
{
a1: {
// data
child: [
{
a2: {
// data
// And so on...
}
}
]
}
},
{
b1: {
// data
child: [
{
b2: {
// data
// And so on...
}
}
]
}
}
]
}
1 answer
-
answered 2022-04-21 10:02
Thennan
MATCH(P)-[:child*n]->(C) RETURN P,C
Will return all the nodes in the 'child' path from node P.
'n' specifies the number of hops between P and C with the child relationship.MATCH(P)-[:child*]->(C) RETURN P,C
Will return all the nodes in the 'child' path, irrespective of the number of child relationship hops in-between.
Reference - Specifying varying length paths
How many English words
do you know?
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
how many words do you know
Powered by Examplum