5

I want to bulk delete nodes in the same way we can bulk load data using a curl operation in AWS Neptune. Is there an API convention for gremlin like I see for SPARQL? If so can you please post reference?

If there is no bulk delete via the API, how feasible is it to bulk delete with the gremlin python sdk?

Justin Gerard
  • 147
  • 1
  • 7

2 Answers2

9

There is an example of how to delete a graph using multi threaded Python at this location. The code could be further improved to work with very large graphs. That is discussed in the comments. I have successfully deleted graphs with 20+ million vertices using this code.

https://github.com/awslabs/amazon-neptune-tools/tree/master/drop-graph

EDITED 2021-11-17 If you want to delete everything, Amazon Neptune now provides a "fast reset" API that allows you to efficiently delete all the data in a cluster.

https://docs.aws.amazon.com/neptune/latest/userguide/manage-console-fast-reset.html

Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38
  • 1
    Thank you Kelvin. Similar question with regard to updating nodes in bulk. Is there a way to update parameters for already existing nodes and edges? – Justin Gerard Mar 12 '20 at 12:05
  • 1
    For Bulk Update (existing vertex properties) and Bulk Add (new vertices) you will most likely be able to use the Neptune Bulk Loader https://docs.aws.amazon.com/neptune/latest/userguide/bulk-load.html In cases where that does not meet your needs you could write a multi threaded updater app/script but I would start by seeing if the Bulk Loader can do what you need. – Kelvin Lawrence Mar 12 '20 at 14:01
0

We can pass batch of elements inside the vertex as an argument like below:

vertex_ids = ['f1b8','e5123','02d49','50804',c71c3','c1061577']
g.V(vertex_ids).drop().iterate()

I was taking a batch size of 10k vertex_ids. It worked fine for me.

RiveN
  • 2,595
  • 11
  • 13
  • 26
  • That is essentially what the Python code referenced in the other answer does. Note that to drop an entire Neptune graph there is also now a REST API available that does thaht. – Kelvin Lawrence Nov 17 '21 at 14:59