How to create, register and enable an index in Janusgraph?

I want to create an index to find a vertex by label and a property value. I saw from documentation that i have to Install->Register->Enable the index, but somehow i can't get it to be Register and Enabled. 1) Install
JanusGraph graph_joy = JanusGraphFactory
.open("/home/white/IdeaProjects/squery-gremlin/conf/janusgraph.properties");

JanusGraphManagement mgmt = graph_joy.openManagement();
mgmt.buildIndex("indexID_05", Vertex.class)
.indexOnly(mgmt.getVertexLabel("user"))
.addKey(mgmt.getPropertyKey("userid")).buildCompositeIndex();

mgmt.commit();
//timeouts see bellow the logs
ManagementSystem.awaitGraphIndexStatus(graph_joy,"indexID_05").call();
JanusGraph graph_joy = JanusGraphFactory
.open("/home/white/IdeaProjects/squery-gremlin/conf/janusgraph.properties");

JanusGraphManagement mgmt = graph_joy.openManagement();
mgmt.buildIndex("indexID_05", Vertex.class)
.indexOnly(mgmt.getVertexLabel("user"))
.addKey(mgmt.getPropertyKey("userid")).buildCompositeIndex();

mgmt.commit();
//timeouts see bellow the logs
ManagementSystem.awaitGraphIndexStatus(graph_joy,"indexID_05").call();
Graph Index | Type | Unique | Backing | Key: Status |
indexID_05 | Composite | false | internalindex | userid: INSTALLED |
Graph Index | Type | Unique | Backing | Key: Status |
indexID_05 | Composite | false | internalindex | userid: INSTALLED |
2) Register? Enable?
mgmt = graph_joy.openManagement();
ManagementSystem.awaitGraphIndexStatus(graph_joy,"indexID_05").call();
mgmt.updateIndex(mgmt.getGraphIndex("indexID_05"), SchemaAction.REGISTER_INDEX).get();
mgmt.commit();
mgmt = graph_joy.openManagement();
ManagementSystem.awaitGraphIndexStatus(graph_joy,"indexID_05").call();
mgmt.updateIndex(mgmt.getGraphIndex("indexID_05"), SchemaAction.REGISTER_INDEX).get();
mgmt.commit();
Didn't work, still remains just installed, i tried enable also, and it said to register first, get from logs a timeout on the awaitGraphIndexStatus();
.....
23-06-06 16:29:05 death INFO [org.janusgraph.graphdb.database.management.GraphIndexStatusWatcher:82] - Some key(s) on index indexID_05 do not currently have status(es) [REGISTERED]: userid=INSTALLED
23-06-06 16:29:05 death INFO [org.janusgraph.graphdb.database.management.GraphIndexStatusWatcher:82] - Some key(s) on index indexID_05 do not currently have status(es) [REGISTERED]: userid=INSTALLED
23-06-06 16:29:05 death INFO [org.janusgraph.graphdb.database.management.GraphIndexStatusWatcher:91] - Timed out (PT1M) while waiting for index indexID_05 to converge on status(es) [REGISTERED]
.....
23-06-06 16:29:05 death INFO [org.janusgraph.graphdb.database.management.GraphIndexStatusWatcher:82] - Some key(s) on index indexID_05 do not currently have status(es) [REGISTERED]: userid=INSTALLED
23-06-06 16:29:05 death INFO [org.janusgraph.graphdb.database.management.GraphIndexStatusWatcher:82] - Some key(s) on index indexID_05 do not currently have status(es) [REGISTERED]: userid=INSTALLED
23-06-06 16:29:05 death INFO [org.janusgraph.graphdb.database.management.GraphIndexStatusWatcher:91] - Timed out (PT1M) while waiting for index indexID_05 to converge on status(es) [REGISTERED]
If someone can give a simple example of how to install->register->enable an index it will help i am stuck.
4 Replies
porunov
porunov2y ago
Your code doesn’t enable an index. You can use .profile() to check if your query uses an index or not. Most likely your query doesn’t use and index
WhiteDeath
WhiteDeathOP2y ago
thank you for helping me, but somehow i can't make it registered before enabling it, Update action [ENABLE_INDEX] cannot be invoked for index with status [INSTALLED] if someone can give a simple example on how to do all 3 steps it will help.
porunov
porunov2y ago
In case you are using JanusGraph <= 0.6.x then indexes lifecycle process is described here: https://docs.janusgraph.org/schema/index-management/index-lifecycle/ In case you are using JanusGraph >= 1.0.0 (not released yet, but rc-2 release is available) then you can find a new index lifecycle documentation here: https://docs.janusgraph.org/master/schema/index-management/index-lifecycle/
WhiteDeath
WhiteDeathOP2y ago
This is what i do the build is ok, but ManagementSystem.awaitGraphIndexStatus(graph, "myIndex").call(); doesn't run ok it timeouts, so my index is not registered, and i can't enable it, and i see the above messages on the logs. i use(but i tried many other berkeley also, and cassandra older versions i couldnt make it register) :
apache-cassandra-4.1.2
And the 1.0.0 version of janusgraph, as library :
[org.apache.tinkerpop/gremlin-driver "3.6.4"]
[org.janusgraph/janusgraph-cql "1.0.0-20230602-001520.bd38731"]
[org.janusgraph/janusgraph-core "1.0.0-20230602-001520.bd38731"]
apache-cassandra-4.1.2
And the 1.0.0 version of janusgraph, as library :
[org.apache.tinkerpop/gremlin-driver "3.6.4"]
[org.janusgraph/janusgraph-cql "1.0.0-20230602-001520.bd38731"]
[org.janusgraph/janusgraph-core "1.0.0-20230602-001520.bd38731"]
Want results from more Discord servers?
Add your server