0

I have janusgraph database, in which all indexes were built.But the status of some of those indexes is installed. Now I am trying to update those Indexes to the registered and then to enabled. So I have done some research and I found this Action(schemaAction).But I don't know the syntax and also how to use graph.openManagement().updateIndex().

Any suggestions regarding this issue or if there is anything other than this procedure, then please let me know it.

Thanks in advance!

stephen mallette
  • 45,298
  • 5
  • 67
  • 135
Himabindu
  • 634
  • 8
  • 22
  • mgmt.updateIndex(mgmt.getGraphIndex("byNameUnique"), SchemaAction.REGISTER_INDEX).get() is for getting the status? – Himabindu May 21 '20 at 09:42
  • I have used this `mgmt.updateIndex(mgmt.getGraphIndex("giftIdByGift"), SchemaAction.REGISTER_INDEX).get()` but ended up with an error The vertex or type is not associated with this transaction [giftIdByGift] – Himabindu May 22 '20 at 09:00

1 Answers1

0

If there are any open transactions while creating the indexes they might get stuck in the INSTALLED state. You can find a clear explanation here. After rolling back your open transactions and closing open instances, try reindexing.

Note: Block until the SchemaStatus transitions from INSTALLED to REGISTERED, after running the reindex command. Try to run groovy script instead of running the commands directly on gremlin console for building the indexes. Please find the sample script below.

import org.janusgraph.graphdb.database.management.ManagementSystem

mgmt = graph.openManagement();
mgmt.updateIndex(mgmt.getGraphIndex("giftIdByGift"), SchemaAction.REGISTER_INDEX).get();
ManagementSystem.awaitGraphIndexStatus(graph, "giftIdByGift").call();
mgmt.commit();

mgmt = graph.openManagement();
mgmt.updateIndex(mgmt.getGraphIndex("giftIdByGift"), SchemaAction.REINDEX).get();
ManagementSystem.awaitGraphIndexStatus(graph, "giftIdByGift").status(SchemaStatus.ENABLED).call();
mgmt.commit();
rajashekar
  • 609
  • 5
  • 19