从 Rexster 中删除 Neo4j 图形的最快方法

Fastest way to delete Neo4j graph from Rexster

我的用例要求我尽快清除图表,以便摄取新图表。我在通过 Rexster 实现的 Neo4j 图中有数百万个顶点和边。我尝试使用 Rexster 界面中的 g.E.remove() 删除具有 280 万条边的图 -

localhost:8182/graphs/neo4jsample/tp/gremlin?script=g.E.remove();

执行此操作需要将近 200 秒(仅删除边缘)。当我的解决方案生效时,我必须在最多 10 秒内清空图形。
我试图删除保存 neo4j 图形 (.db) 文件的文件夹(默认为 /tmp/neo4j-graph)。即使在这样做之后,Rexster returns 也会对 gremlin 查询产生结果(就像在删除 neo4j-graph 之前一样)。我猜这是因为当 Rexster 服务器启动时正在缓存该图。 作为上述步骤的进展,我首先关闭图表

localhost:8182/graphs/neo4jsample/tp/gremlin?script=g.shutdown();

.. 然后删除 'neo4j-graph' 文件夹。然后我尝试用

创建一个新的图形文件夹
localhost:8182/graphs/neo4jsample/tp/gremlin?script=g = new Neo4jGraph('/tmp/neo4j-graph')

坚持这个位置,因为这是在 'rexster.xml' 中配置的。现在创建了一个新的 'neo4j-graph' 文件夹,其中包含创建的所有 Neo4j '.db' 文件。 任何带有 g (g.V.map(), g.addVertex([name:"John Doe",age:50])) 的 gremlin 查询现在都会抛出错误,其中我发现可以理解的错误是 -

 org.neo4j.graphdb.TransactionFailureException: Database is currently not available. No blocking components

在这种情况下,有什么方法可以让 'g' 再次正常工作(无需重新启动 Rexster)?
有没有比我提到的更快的删除整个图的方法?

您的做法是正确的,shutdown()并删除了数据目录。请注意,即使是 Neo4j Server 也以这种方式工作 (requiring shutdown)。不幸的是,这需要重新启动 Rexster 才能重新生成新鲜的 Neo4j 图。