Creating Indexes In JanusGraph

How do you create indices in JanusGraph and/or Gremlin with Java?

JanusGraph still isn't using the index provided.

2023-05-15 14:35:59,723 [INFO] [o.j.g.d.m.ManagementSystem.Thread-25] ::     Index update job successful for [_id]
2023-05-15 14:35:59,724 [WARN] [o.j.g.t.StandardJanusGraphTx.main] ::     Query requires iterating over all vertices [[~label = entity]]. For better performance, use indexes
2023-05-15 14:35:59,726 [INFO] [Main.main] ::     REINDEX g.V().hasLabel("entity").count().next():    1
2023-05-15 14:35:59,737 [WARN] [o.j.g.t.StandardJanusGraphTx.main] ::     Query requires iterating over all vertices [[_id <> null]]. For better performance, use indexes
2023-05-15 14:35:59,738 [INFO] [Main.main] ::     REINDEX g.V().hasLabel("entity").count().next():    1
2023-05-15 14:35:59,739 [WARN] [o.j.g.t.StandardJanusGraphTx.main] ::     Query requires iterating over all vertices [[~label = entity, _id <> null]]. For better performance, use indexes
2023-05-15 14:35:59,740 [INFO] [Main.main] ::     REINDEX g.V().hasLabel("entity").count().next():    1


        JanusGraph janusGraph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
        GraphTraversalSource g = janusGraph.traversal();
...   janusGraphManagement.updateIndex(janusGraphManagement.getGraphIndex("_id"), SchemaAction.REINDEX).get();
        janusGraphManagement.commit();
        logger.info("REINDEX g.V().hasLabel(\"entity\").count().next():\t" + g.V().hasLabel("entity").count().next());
        logger.info("REINDEX g.V().hasLabel(\"entity\").count().next():\t" + g.V().has("_id").count().next());
        logger.info("REINDEX g.V().hasLabel(\"entity\").count().next():\t" + g.V().hasLabel("entity").has("_id").count().next());
Was this page helpful?