I have a source of data which I read and try to load it into my CosmosDB Graph. Each row that I fetch contains an information about multiple entities (person, software). What I am trying to do here is to:
- verify if such a vertex(es) already exist and generate a separate entity for missing entries (person, software)
- verify if an edge already exists (between this person and this software)
- create an edge between them
I've been making a reference to the following topics: CosmosDB Graph : “upsert” query pattern, Add edge if not exist using gremlin trying to combine them somehow but without much of a success.
I have tried the following:
g.V().has('person','name','vadas').
fold().coalesce(unfold(), addV('person').property('name','vadas')).as('v').
V().has('software', 'name','ripple').
fold().coalesce(unfold(), addV('software').property('name','ripple')).
coalesce(__.inE('created').where(outV().as('v')), addE('created').from('v'))
but it only creates the vertices without the edge between them.
I am also wondering if there's a bit more common approach to kind of:
1. Upsert entity A and keep a reference to it
2. Upsert entity B and keep a reference to it
3. Upsert entity C and keep a reference to it
....
1. Upsert edge between A and B
2. Upsert edge between A and C