Skip to content

Overwrite existing edge in Neptune graph Database

0

Let's say I have following 2 nodes and 1 edge loaded into Neptune

1.) project

project_idproject_name
123Irrigation

2.) country

country_idcountry_name
20Argentina
21India

and edge data

start_id(project)end_id(country)TYPEID
12320IS_INproject_country_123

Now I got a new edge for the same project_id but different country

start_id(project)end_id(country)TYPEID
12321IS_INproject_country_123

when i load above edge data i am getting error (ID_ASSIGNED_TO_MULTIPLE_EDGES) because of duplicate edge ID(project_country_123). But i want it to overwrite the existing data if there's a same edge id. i.e., If the edge_id already exists it should drop the existing edge_id and load new.

what are the possible solutions do I have.

I use opencypher format to load data into Neptune. nep_client.start_loader_job( source='s3://bucket/Test.csv', format='opencypher', s3BucketRegion='us-east-1', iamRoleArn='arn:aws:iam::12345678:role/NeptuneLoadFromS3' , mode='AUTO', failOnError=False, parallelism='MEDIUM', queueRequest=True )

  • Can someone please give me an update on this. Thank you!

asked 2 years ago724 views

1 Answer
1

The Neptune bulk loader does not contain logic to perform conditional writes on edges like this. It can update property values, or append new data. But it cannot do deletes or any sort of conditional writes.

If you want to use the bulk loader in this sort of pattern, you'll likely want to store a datetime value as a property on your edges. You can then use the datetime/timestamp to find the most recent outgoing edge from a project to a country. If you are then worried about the graph becoming too large

But if you want to upsert edges like this, you'll have to move from using the bulk loader to issuing openCypher or Gremlin queries to write the data into Neptune.

AWS

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.