查看索引
mgmt = graph.openManagement()# 查看全部点索引mgmt.getGraphIndexes(Vertex.class)# 查看全部边索引mgmt.getGraphIndexes(Edge.class)# 查看某个索引的状态mgmt.getGraphIndex('indexname').getIndexStatus(mgmt.getPropertyKey('J010006'))
索引状态由 INSTALLED 改为 REGISTERED
# 回滚事务graph.getOpenTransactions().forEach{tx->tx.rollback()}# 更改之前必须关闭所有 instance,否则更改不成功mgmt = graph.openManagement()# all open instancesmgmt.getOpenInstances() ==>7f0001016161-dunwich1(current)==>7f0001016161-atlantis1# 删除一个 instance 带有current的是当前的mgmt.forceCloseInstance('7f0001016161-atlantis1') mgmt.commit()mgmt = graph.openManagement()mgmt.updateIndex(mgmt.getGraphIndex("${indexName}"), SchemaAction.REGISTER_INDEX).get()# 也可以使用这个 API 效果一样ManagementSystem.awaitGraphIndexStatus(graph, '${indexName}').call()# 查询状态mgmt.getGraphIndex('${indexName}').getIndexStatus(mgmt.getPropertyKey('${prop}'))mgmt.commit()
索引reindex
# reindex 速度非常慢,即使reindex完成后再进行reindex速度也没有明显减少mgmt = graph.openManagement()i = mgmt.getGraphIndex('indexName')mgmt.updateIndex(i, SchemaAction.REINDEX).get()mgmt.commit()# 使用MapReduce时,需要export HADOOP_HOME等