titan - 如何删除 JanusGraph 索引?

标签 titan 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

最佳答案

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

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

mgmt = graph.openManagement()

mgmt.getOpenInstances() //all open instances

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

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

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

// 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()

我遇到了同样的问题并尝试了很多其他的东西,最后上面的过程成功了!

关于titan - 如何删除 JanusGraph 索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45273709/

相关文章:

java - 通过 Gremlin 连接到 DynamoDB Local

gremlin - 为什么后续的 "has"步骤会使 Gremlin 查询明显变慢?

python - 有没有办法将 gremlinpython 图转换为 networkx 图

python - asyncio - 有多少协程?

apache-spark - 从 Titan(在 HBase 上)读取大图到 Spark

c# - 将 titan graph db 与 c# 和 gremlin 结合使用

groovy - 灯泡:g.scripts.update():TypeError:序列项 2:预期字符串或 Unicode,未找到 NoneType

hbase - titan如何存储顶点id(将顶点id转换为HBase键列)?

nosql - 获取沿路径具有特定属性、标签和 ID 的所有顶点

gremlin - 使用 Gremlin 将 Tinkergraph 子图导出到文件