Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-02-2020 01:36 PM
Hi,
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.
Please help.
Thanks
10-02-2020 02:14 PM
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
10-02-2020 02:29 PM
Thanks for the response
I guess 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
10-02-2020 02:49 PM
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.
10-02-2020 03:07 PM
OK, as I am new to neo4j I am trying to setup the apoc plugins
I will reply as soon as I succeed
10-03-2020 07:10 AM
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
10-03-2020 11:14 AM
Please share the query that you ran so that I can understand the issue.
All the sessions of the conference are now available online