2017-07-24 96 views
2

但是索引状态被安装,如何将状态更改为临时用户,然后禁用它来删除它,请帮助我,如何删除JanusGraph索引?

GraphTraversalSource g = janusGraph.traversal(); 
    JanusGraphManagement janusGraphManagement = janusGraph.openManagement(); 
    JanusGraphIndex phoneIndex = 
    janusGraphManagement.getGraphIndex("phoneIndex"); 
    PropertyKey phone = janusGraphManagement.getPropertyKey("phone"); 
    SchemaStatus indexStatus = phoneIndex.getIndexStatus(phone); 
    String name = phoneIndex.name(); 
    System.out.println(name); 
    if (indexStatus == INSTALLED) { 
     janusGraphManagement.commit(); 
     janusGraph.tx().commit(); 

image

回答

0

你必须拳头禁用索引,那么你可以删除它。

// Disable the "phoneIndex" composite index 
janusGraphManagement = janusGraph.openManagement() 
phoneIndex = janusGraphManagement.getGraphIndex('phoneIndex') 
janusGraphManagement.updateIndex(phoneIndex, SchemaAction.DISABLE_INDEX).get() 
janusGraphManagement.commit() 
janusGraph.tx().commit() 

// Block until the SchemaStatus transitions from INSTALLED to REGISTERED 
ManagementSystem.awaitGraphIndexStatus(janusGraph, 'phoneIndex').status(SchemaStatus.DISABLED).call() 

// Delete the index using TitanManagement 
janusGraphManagement = janusGraph.openManagement() 
phoneIndex = janusGraphManagement.getGraphIndex('phoneIndex') 
future = janusGraphManagement.updateIndex(phoneIndex, SchemaAction.REMOVE_INDEX) 
janusGraphManagement.commit() 
janusGraph.tx().commit() 
+0

当我在janusGraph上建立索引时,索引状态是安装,它不能启用,所以索引状态被安装它不能删除 – lazyfighter

1

如果无法改变索引的状态,从安装启用,我建议你检查JanusGraph的运行情况,并关闭所有的情况下,除了一个带“(当前)”,然后尝试再次删除索引。

要检查并关闭实例在小鬼外壳使用下面的命令:

// Disable the "name" composite index 
this.management = this.graph.openManagement() 
def nameIndex = this.management.getGraphIndex(indexName) 
this.management.updateIndex(nameIndex, SchemaAction.DISABLE_INDEX).get() 
this.management.commit() 
this.graph.tx().commit() 

// Block until the SchemaStatus transitions from INSTALLED to REGISTERED 
ManagementSystem.awaitGraphIndexStatus(graph, indexName).status(SchemaStatus.DISABLED).call() 

// Delete the index using JanusGraphManagement 
this.management = this.graph.openManagement() 
def delIndex = this.management.getGraphIndex(indexName) 
def future = this.management.updateIndex(delIndex, SchemaAction.REMOVE_INDEX) 
this.management.commit() 
this.graph.tx().commit() 

我面临着同样的问题,并尝试了很多其他的事情:

mgmt = graph.openManagement() 

mgmt.getOpenInstances() //all open instances 

==>7f0001016161-dunwich1(current) 
==>7f0001016161-atlantis1 

mgmt.forceCloseInstance('7f0001016161-atlantis1') //remove an instance 
mgmt.commit() 

删除索引使用下面的代码然后最终上述过程奏效!