Dropping graph schema
Dropping (deleting) graph schema.
Schema can be dropped (deleted) using the drop()
step; see propertyKey, vertexLabel, and edgeLabel for more
information.
Procedure
Drop schema
-
To drop the schema and all data without dropping the graph, use a
drop()
step. Runningdescribe()
after will verify that the schema is dropped. After the schema is dropped, new schema and data can be loaded to the graph.To drop all schema:schema.drop()
=>null
-
To drop schema for a particular property key, specify the property key and then
use the
drop()
step:schema.propertyKey('aBadProperty').drop()
Warning: To drop a property key for a vertex label that has a materialized view index, additional steps are required to prevent data loss or cluster errors. Drop any materialized indexes for the vertex label, drop the property key, and then rebuild the schema for the materialized view indexes. The MV index data will be recreated from the base table, with the exception of the data for the dropped property key. -
To drop schema for a particular vertex label, specify the vertex label and then
use the
drop()
step:schema.vertexLabel('aBadVertexLabel').drop()
Drop index
-
To drop an index from the schema, such as the
byMeal
index, identify the index by name. Usedescribe()
to examine all indexes for the desired vertex label first.schema.vertexLabel('meal').describe()
==>schema.vertexLabel('meal').properties("name").create() schema.vertexLabel('meal').index('byMeal').materialized().by('name').add()
-
Using the vertex label and index name, remove the index. Running
describe()
again will verify that the index is removed.schema.vertexLabel('meal').index('byMeal').drop()
==>null
-
Remove only one property from a search index:
schema.vertexLabel('author').index('search').search().properties('nick_name').drop() schema.vertexLabel('author').describe()
Clean up
-
If schema changes cause inconsistencies in the graph data, OLAP analytic
operations can be blocked and queries will not run. Use the graph cleanup tool
to remove any orphaned edge or unattached vertex properties that cause
problems.
For example, after removing an edgelabel:
graph.schema().edgeLabel("emailed").drop()
Set the graph test_graph to analytics mode and run a cleanup:// Set the graph to OLAP mode :remote config alias g test_graph.a // Allow full scans schema.config().option('graph.allow_scan').set('true') // Run the cleanup graph.cleanUp()
The results details the cleanup actions:
==> Edges with unknown labels deleted: 8 Orphaned edges deleted: 0 Unattached vertex properties deleted: 0 Graph cleanup finished at 20 seconds Please run `nodetool repair -pr test_graph` on each cluster node to finish the cleanup
Note that a nodetool repair command will be required post-cleanup.