查看索引

  1. mgmt = graph.openManagement()
  2. # 查看全部点索引
  3. mgmt.getGraphIndexes(Vertex.class)
  4. # 查看全部边索引
  5. mgmt.getGraphIndexes(Edge.class)
  6. # 查看某个索引的状态
  7. mgmt.getGraphIndex('indexname').getIndexStatus(mgmt.getPropertyKey('J010006'))

索引状态由 INSTALLED 改为 REGISTERED

  1. # 回滚事务
  2. graph.getOpenTransactions().forEach{tx->tx.rollback()}
  3. # 更改之前必须关闭所有 instance,否则更改不成功
  4. mgmt = graph.openManagement()
  5. # all open instances
  6. mgmt.getOpenInstances()
  7. ==>7f0001016161-dunwich1(current)
  8. ==>7f0001016161-atlantis1
  9. # 删除一个 instance 带有current的是当前的
  10. mgmt.forceCloseInstance('7f0001016161-atlantis1')
  11. mgmt.commit()
  12. mgmt = graph.openManagement()
  13. mgmt.updateIndex(mgmt.getGraphIndex("${indexName}"), SchemaAction.REGISTER_INDEX).get()
  14. # 也可以使用这个 API 效果一样
  15. ManagementSystem.awaitGraphIndexStatus(graph, '${indexName}').call()
  16. # 查询状态
  17. mgmt.getGraphIndex('${indexName}').getIndexStatus(mgmt.getPropertyKey('${prop}'))
  18. mgmt.commit()

索引reindex

  1. # reindex 速度非常慢,即使reindex完成后再进行reindex速度也没有明显减少
  2. mgmt = graph.openManagement()
  3. i = mgmt.getGraphIndex('indexName')
  4. mgmt.updateIndex(i, SchemaAction.REINDEX).get()
  5. mgmt.commit()
  6. # 使用MapReduce时,需要export HADOOP_HOME等