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
store
vertex 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
ate
edge 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
person
Fritz Streiff, by identifying the vertex along with adrop
traversal 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 adrop
traversal step.g.E().has('ate', 'name','Fritz STREIFF').drop()
-
Drop a specific value by identifying the vertices with the property value along with a
drop
traversal step:g.V().hasLabel('person').properties('gender').hasValue('M').drop()
This query will drop the
gender
value for all person vertices that have agender
equal 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 = M
values. -
Drop a property key from an edge, such as
reviewed
edges, by identifying the edges and the property keystars
, and adrop
traversal step.g.E().hasLabel('reviewed').properties('stars').drop()
This query will drop the property key
stars
for all edges that have areviewed
edge 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
stars
values.