如何使用graph.openManagement().updateIndex()?

How to use graph.openManagement().updateIndex()?

我有 janusgraph 数据库,其中所有索引都是 built.But 其中一些索引的状态已安装。现在我正在尝试将这些索引更新为已注册然后启用。所以我做了一些研究,我发现了这个 Action(schemaAction)。但我不知道语法以及如何使用 graph.openManagement().updateIndex()

关于这个问题的任何建议,或者除了这个过程之外还有什么,请告诉我。

提前致谢!

如果在创建索引时有任何打开的事务,它们可能会卡在已安装状态。 你可以找到一个明确的解释。 回滚打开的事务并关闭打开的实例后,尝试重建索引。

注意: 在 运行 执行重新索引命令后,阻止 SchemaStatus 从已安装到已注册。尝试 运行 groovy 脚本而不是 运行 直接在 gremlin 控制台上使用命令来构建索引。请在下面找到示例脚本。

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