Janusgraph: Document dropping data, schema and graphs using gremlin groovy commands

Created on 7 Mar 2017  Â·  10Comments  Â·  Source: JanusGraph/janusgraph

It would be beneficial to the community to have the commands required to drop the data, schema and graphs within the Getting Started documentation: http://docs.janusgraph.org/0.1.0-SNAPSHOT/getting-started.html

The only commands that I know are below (Cassandra + ES specific).

$ curl -XDELETE localhost:9200/janusgraph
{"acknowledged":true}
$ /usr/bin/cqlsh localhost
Connected to JanusGraph Cassandra Cluster at localhost:9042.
[cqlsh 5.0.1 | Cassandra 2.1.17 | CQL spec 3.2.1 | Native protocol v3]
Use HELP for help.
cqlsh> DROP KEYSPACE janusgraph;

Is there a better way to do this from within the Gremlin shell?

aredocs

Most helpful comment

Thanks for the suggestion. There are other cleanup approaches, in addition to the one you mentioned.

  • graph.close(); org.janusgraph.core.util.JanusGraphCleanup.clear(graph) will clear the data in the backend storage and index providers. This works generically against any of the backends.
  • If you're using ./bin/janusgraph.sh start as described in the pre-packaged distribution docs, then you can stop the servers with ./bin/janusgraph.sh stop, then remove the directories ./db/cassandra and ./db/es.

@MichaelMarkieta Would you be interested in submitting a pull request for this? See Contributing to JanusGraph.

All 10 comments

Thanks for the suggestion. There are other cleanup approaches, in addition to the one you mentioned.

  • graph.close(); org.janusgraph.core.util.JanusGraphCleanup.clear(graph) will clear the data in the backend storage and index providers. This works generically against any of the backends.
  • If you're using ./bin/janusgraph.sh start as described in the pre-packaged distribution docs, then you can stop the servers with ./bin/janusgraph.sh stop, then remove the directories ./db/cassandra and ./db/es.

@MichaelMarkieta Would you be interested in submitting a pull request for this? See Contributing to JanusGraph.

@pluradj thanks, I will submit the PR later today or tomorrow.

janusgraph.sh also supports a clean option which deletes the aforementioned directories and some log files but it assumes that they are in default locations.

@MichaelMarkieta — was there a PR submitted to address this issue? Can you link to it from here, or link to this issue from the PR so that it's easy to connect the discussion to the implementation?

I was checking the docs today for the same info proposed by this issue and could not find it. I'll throw in a PR tomorrow to add in general steps for dropping a graph as well as the commands to refresh the graph of the gods example.

@pluradj The problem I see with dropping databases through this code:
graph.close(); org.janusgraph.core.util.JanusGraphCleanup.clear(graph)
and this one:
graph.close(); org.janusgraph.core.JanusGraphFactory.drop(graph)

is that it won't work if the JanusGraph version changes (i.e. from 0.2.0 to 0.3.0 or vice versa). Correct me if I am wrong. I think, it would be better if there would be a possibility to build a JanusGraph instance without opening a connection. I didn't find the solution yet.

@porunov what do you mean by it won't work if the version changes? I've tested dropped graphs that have been upgraded from 0.2.0 to 0.3.0 and it works fine. Also you can't connect to 0.2.0 graphs with a 0.3.0 client without performing an upgrade. Dropping an 0.2.0 graph with 0.2.1 should work as far as I know.

Also if it helps here's what ended up being documented for dropping graphs, even though it's not live on the docs site yet.

With ConfiguredGraphFactory

graph = ConfiguredGraphFactory.open('example')
ConfiguredGraphFactory.drop('example');

With JanusGraphFactory

graph = JanusGraphFactory.open('path/to/configuration.properties')
JanusGraphFactory.drop(graph);

Separately from the example in the issue description what really should have been documented was tips and commands for managing the specific mixed indexes. Currently you cannot drop a mixed index using gremlin console currently and need to do it through solr, es, and lucene. I think there's also a feature gap that after manually deleting an index there is currently no way to remove the reference to it with the gremlin console.

@chupman Thanks for clearing it up. Do you know how to upgrade from 0.2.0 to 0.3.0? I didn't find information about it.

You actually did a review on the PR https://github.com/JanusGraph/janusgraph/pull/998, but the name isn't very clear. It's not merged yet, but tagged for the 0.3.0 release.

@chupman Yes, I did review that PR but I was checking only Java code. I didn't even read doc changes. It's really useful information there. Thank you! My issue is resolved.

Was this page helpful?
0 / 5 - 0 ratings