Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-15-2022 12:26 AM
Warm Greetings to Neo4j Community!
We've following requirement which we are trying to address in Neo4j -
A Node is connected to another Node through many relationships, and each of these relationships capture a number of metrics based on a given date. For e.g
(A) -[:HAS {metric: 'a1', date: '2021-10-10', value: 40}]->(B)
(A) -[:HAS {metric: 'a2', date: '2021-10-10', value: 60}]->(B)
(A) -[:HAS {metric: 'a3', date: '2021-10-10', value: 70}]->(B)
(A) -[:HAS {metric: 'a4', date: '2021-10-10', value: 10}]->(B)
2. There is a need to Create New relationships between A and B, which will contain exactly the same information as existing relationships except the 'date' property, which is to be updated with a new date.
(A) -[:HAS {metric: 'a1', date: '2021-10-12', value: 40}]->(B)
(A) -[:HAS {metric: 'a2', date: '2021-10-12', value: 60}]->(B)
(A) -[:HAS {metric: 'a3', date: '2021-10-12', value: 70}]->(B)
(A) -[:HAS {metric: 'a4', date: '2021-10-12', value: 10}]->(B)
3. Requirement is not to Update the existing relations. Only Create new relations with new 'date' but rest of the properties on the relations should be same.
Considering that there exists 100+ such relationships between A and B for a given date, can we copy(utilize) the existing relations between A and B, and create new relations based on that copied info, with updated 'date' property.
Can you please advice is there an easy way to achieve the objective.
05-15-2022 09:05 PM
You can try this. Replace the match(A) and match(B) where predicates with you actual conditions to identify nodes A and B.
match(A) where id(A) = 1
match(B) where id(B) = 2
match (A)-[r_existing:HAS {metric: 'a1', date: '2021-10-12'}]->(B)
merge (A)-[r_new:HAS]->(B)
set r_new = r_existing, r_new.date = $newDate
All the sessions of the conference are now available online