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.

Is there a merge option for apoc.create.vRelationship

To prevent duplicate virtual relationships from being created; is there an option for something similar to apoc.merge.vRelationship

I am creating multiple relationships and RETURNing it. The YEILD of the COLLECTion is at the lowest grain. One relationship is at the lowest grain, the other relationship is aggregated and at a higher level.I am getting duplicate of the aggregated realationship

As an example:

             Year >>>>> Month >>>>> Day >>>> Channel {Num of Interactions}

So I have data like

             2018, Jun, 18, ABC (200)
             2018, Jun, 18, DEF (400)
             2018, Jun, 18, DEF (100)
             2018, Jun, 19, ABC (20)
             2018, Jun, 19, DEF (40)

When I UNWIND this collection;

  Row 1: 2018, Jun, 18, ABC (200)
             apoc.create.vRelationship for 18 to ABC
             apoc.merge.vRelationship for Jun to 18
            apoc.merge.vRelationship for 2018 to Jun

And Then

  Row 2: 2018, Jun, 18, DEF (400)
             apoc.create.vRelationship for 18 to DEF
             apoc.merge.vRelationship for Jun to 18
            apoc.merge.vRelationship for 2018 to Jun

I know there are workarounds in getting to this with the apoc.create; but really hoping if there is a way to apoc.merge (currently or in the future)

Regards
Sreekanth

2 REPLIES 2

I really need this functionality too!

I have a large graph showing dependencies within data and am getting a large number of duplicate virtual relationships when I try to use them to depict high level dependencies on databases while skipping the tables.

I'm fairly new to cypher and haven't managed to find a work around for this yet either.

Do a distinct collect() and create relationships like this :

[x IN customers[..10] | apoc.create.vRelationship (p, 'COLLABD',{}, x) ]
Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online