cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Bill of materials

I want to store a Bill of materials(BOM) in neo4j. It is a tree schema.
below will be the queries :

  1. Get Complete tree for a product/part
  2. Get all the descendants of a node
  3. Get all the ascendents of a node
  4. Get all the descendants of a node restricted to a level n
  5. Get all the ascendents of a node restricted to a level n
  6. Get level nth ascendant of a node
  7. Get level nth descendent of a node

I want the output as a tree. In a nested manner.
for e.g:

{
type:"transport",
name:"xyz",
child:[{
type:"airways",
name:"pqr"
},{
type:"waterways",
name:"qwe",
child:
[{
type:"ships",
name:"asd"
},{
type:"sub-marine",
name:"cfv"
},]}}{
type:"roadways",
name:"dffd"
}]}

1 ACCEPTED SOLUTION

Personally I would do most of these transforms in a different scripting language, but there seem to be an APOC procedure you can use: apoc.convert.toTree

First, you should get acquainted with CYPHER and try fetching the data with queries in the browser, then deal with the output format later...

View solution in original post

3 REPLIES 3

Thank you @Thomas_Silkjaer. I am new to neo4j. Can you please help me with a sample query to get the output as nested structure. The number of nested levels(height of the tree) is not known before as the tree is dynamic and nodes can be added or deleted over the time.

Personally I would do most of these transforms in a different scripting language, but there seem to be an APOC procedure you can use: apoc.convert.toTree

First, you should get acquainted with CYPHER and try fetching the data with queries in the browser, then deal with the output format later...