How to remove JanusGraph index?

but the index status is set, how to change the status for registration and then disable it to delete it, please help me,

  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

+3


source to share


2 answers


If you are unable to change the index status from Install to Enable, I suggest you check the running instances of JanusGraph and close all but one with "(Current)" and then try deleting the index again.

To check and close instances, use the following command in a gremlin shell:

mgmt = graph.openManagement()

mgmt.getOpenInstances() //all open instances

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

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

      



To drop the index use the following code:

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

      

I ran into the same problem and tried a lot of other things and then finally work on this procedure!

+2


source


You must first disable the index and then drop it.



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


source







All Articles