首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何删除JanusGraph索引?

如何删除JanusGraph索引?
EN

Stack Overflow用户
提问于 2017-07-24 14:11:30
回答 2查看 2.7K关注 0票数 3

但是索引状态是已安装的,如何将状态更改为registed,然后将其禁用以删除它,请帮助我。

代码语言:javascript
复制
  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();

EN

回答 2

Stack Overflow用户

发布于 2017-08-14 20:19:33

如果您无法将索引的状态从Install更改为Enable,我建议您检查正在运行的JanusGraph实例,并关闭除"(Current)“之外的所有实例,然后再次尝试删除索引。

要检查并关闭实例,请在gremlin shell中使用以下命令:

代码语言:javascript
复制
mgmt = graph.openManagement()

mgmt.getOpenInstances() //all open instances

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

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

要删除索引,请使用以下代码:

代码语言:javascript
复制
// 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()

我遇到了同样的问题,并尝试了很多其他的东西,最后上面的程序起作用了!

票数 2
EN

Stack Overflow用户

发布于 2017-07-24 14:23:10

必须先禁用索引,然后才能将其删除。

代码语言:javascript
复制
// 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()
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45273709

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档