I have a tree with 50K nodes. I need to form a sub-tree based on a property called "balance", I want to start from root and create new relationships between nodes with balance of 100 and higher.
I want this relationship to be like my original tree just a compressed version, I mean if I query this "MATCH p =(n)-[:Compressed*..]->(m) return p" it return a new tree with only nodes with acceptable balances.
Try something like this: MATCH (a:root) MATCH (b:Some) where 300 < b.balance < 600 WITH b order by id(b) ASC WITH (COLLECT(a) + COLLECT(b)) as col1 CALL apoc.nodes.link(col1, 'COMPRESSED') RETURN col1
Thanks for the response
order by id(b) ASC sorts the nodes based on their IDs, but what if ID of a parent is higher than a child?
I guess this will not work then
You can comment out that WITH clause and use it. Here id is the system generated and parent node is expected to be created before child nodes.
When you run the Cypher query in browser you can see the id of a node at the bottom left when a node is highlighted.
OK, as I am new to neo4j I am trying to setup the apoc plugins
I will reply as soon as I succeed
I tried the query unfortunately it created many relationships and didn't work.
is there a way to find the first child of a node with certain property?
I can get the first child in every path of a node with balance of 100 or higher and create a relationship between them
Please share the query that you ran so that I can understand the issue.