如何删除JanusGraph索引?


荧惑
2025-03-15 07:47:24 (24天前)


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

GraphTraversalSource g = janusGraph.traversal();
JanusGraphManagement …

3 条回复
  1. 0# 早岁那知世事艰 | 2019-08-31 10-32



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



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




    1. mgmt = graph.openManagement()

    2. mgmt.getOpenInstances() //all open instances

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

    4. mgmt.forceCloseInstance(‘7f0001016161-atlantis1’) //remove an instance
      mgmt.commit()

    5. </code>


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




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

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

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

    4. </code>


    我遇到了同样的问题并尝试了很多其他的事情,最后上面的程序工作了!


  2. 1# 薄情 | 2019-08-31 10-32




    您必须先禁用索引,然后才能将其删除。
    </强>




    1. // Disable the “phoneIndex” composite index
      janusGraphManagement = janusGraph.openManagement()
      phoneIndex = janusGraphManagement.getGraphIndex(‘phoneIndex’)
      janusGraphManagement.updateIndex(phoneIndex, SchemaAction.DISABLE_INDEX).get()
      janusGraphManagement.commit()
      janusGraph.tx().commit()

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

    3. // Delete the index using TitanManagement
      janusGraphManagement = janusGraph.openManagement()
      phoneIndex = janusGraphManagement.getGraphIndex(‘phoneIndex’)
      future = janusGraphManagement.updateIndex(phoneIndex, SchemaAction.REMOVE_INDEX)
      janusGraphManagement.commit()
      janusGraph.tx().commit()

    4. </code>

登录 后才能参与评论