Dropping graph data
Drop specific edges or vertices based by name or label, or drop all data within a specific graph in DataStax Graph (DSG).
Procedure
-
Drop all data without dropping a graph and schema by dropping all the vertices:
g.V().drop() -
Drop all data without dropping a graph and schema by dropping all the edges:
g.E().drop() -
Drop all vertices with a specific vertex label, such as the
storevertex label:g.V().hasLabel('store').drop()If a very large number of vertices will be dropped with the command shown above, DSG may complain. In that case, modify the
drop()command with a limit of 100 vertices:g.V().hasLabel('store').limit(100)drop()Repeat until all vertices are dropped.
-
Drop all edges with a specific edge label, such as the
ateedge label:g.E().hasLabel('ate').drop()If a very large number of edges will be dropped with the command shown above, DSG may complain. In that case, modify the
drop()command with a limit of 100 edges:g.E().hasLabel('ate').limit(100).drop()Repeat until all edges are dropped.
-
Drop a specific vertex, such as the
personFritz Streiff, by identifying the vertex along with adroptraversal step.g.V().has('person', 'name','Fritz STREIFF').drop()When dropping a vertex, you might need to build additional indexes, so that hanging edges will not be left by removing the vertex. An error message will display suggested solutions, such as creating a particular index or suppressing the exception and leaving possible hanging edges in the graph.
-
Drop a specific edge, such as the
ate, by identifying the edge along with adroptraversal step.g.E().has('ate', 'name','Fritz STREIFF').drop() -
Drop a specific value by identifying the vertices with the property value along with a
droptraversal step:g.V().hasLabel('person').properties('gender').hasValue('M').drop()This query will drop the
gendervalue for all person vertices that have agenderequal toM.==>{gender=[F], name=[Julia Child]} ==>{gender=[F], name=[Patricia Curtan]} ==>{gender=[F], name=[Kelsie Kerr]} ==>{gender=[F], name=[Simone Beck]} ==>{gender=[F], name=[Alice Waters]} ==>{gender=[F], name=[Patricia Simon]} ==>{name=[James Beard]} ==>{name=[Fritz Streiff]} ==>{name=[Emeril Lagasse]}The result returns no
gender = Mvalues. -
Drop a property key from an edge, such as
reviewededges, by identifying the edges and the property keystars, and adroptraversal step.g.E().hasLabel('reviewed').properties('stars').drop()This query will drop the property key
starsfor all edges that have areviewededge label.==>{year=2014-01-23, time=12:00} ==>{year=2014-02-01, comment=Yummy!, time=12:00} ==>{year=2015-12-30, comment=Loved this soup! Yummy vegetarian!, time=12:00} ==>{year=2015-12-31, comment=It was okay., time=12:00} ==>{year=2014-07-23, comment=Too spicy for me. Use less garlic., time=12:00} ==>{year=2014-01-01, comment=Pretty tasty!, time=12:00} ==>{year=2015-12-31, comment=Really spicy - be careful!, time=12:00}The result returns no
starsvalues.