cancel
Showing results for 
Search instead for 
Did you mean: 

Crete new node based on the common property from the existing nodes

Hi All,

I am trying to create a new node based on the common property found in the existing nodes. Say for example, I have two nodes Car1 and Car2. Both have the same property color:'blue'. Now I want to create a new node called Color and create a relationship between the Cars and the Color.

I am running the below query to achieve the same but I getting the memory error.

MATCH (n:Car)
UNWIND n.color AS color
WITH  color, collect(n) AS cars
MERGE (c:Color {car_color:color})
WITH c, cars
UNWIND cars AS n
WITH c,n
MERGE (n)-[:GROUP_TYPE]->(c);
 
But as I have 10k nodes, running this command is throwing the memory error. 
 
'The allocation of an extra 273.2 MiB would use more than the limit 250.0 MiB. Currently using 2.8 MiB. dbms.memory.transaction.global_max_size threshold reached'
 
Can someone help me optimize the query. Thanks a lot
1 REPLY 1

Cobra
Ninja
Ninja

Please do not open multiple threads for the same issue. You got an answer here.

Regards,
Cobra

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.