many graphs

I'm a little confused about accessing graphs. I have ideas for two unrelated graphs. For now, in my gremlin server yaml i have four graphs (while i'm learning) graphs: { graph: conf/janusgraph-inmemory.properties, ConfigurationManagementGraph: conf/janusgraph-cql-configurationgraph.properties, pbrgraph: conf/janusgraph-cql-pbrgraph.properties, gardengraph: conf/janusgraph-cql-gardengraph.properties } I can list these in the Console, gremlin> JanusGraphFactory.getGraphNames() ==>pbrgraph ==>gardengraph ==>graph ==>ConfigurationManagementGraph But to operate on one of them i have to open using the path to the properties file, gremlin> graph = JanusGraphFactory.open( 'conf/janusgraph-cql-pbrgraph.properties' ) ==>standardjanusgraph[cql:[127.0.0.1]] Why can't i just open it using the graph name? gremlin> graph = JanusGraphFactory.open( 'pbrgraph' ) Backend shorthand unknown: pbrgraph
Solution:
You then also don't need JanusGraphFactory.open() any more since JanusGraph Server already opened the graph instances for you. By using the JanusGraphFactory directly in Gremlin Console you basically circumvent this whole functionality from JanusGraph Server and instead access the JanusGraph API directly to load the graphs yourselves. This means that it doesn't know about your Gremlin Server YAML which also explains why you cannot use graph names defined in that YAML...
Jump to solution
3 Replies
Florian Hockmann
JanusGraph Server (which is just Gremlin Server with libraries & config loaded for JanusGraph) loads these graphs already on startup. You can also tell the server to bind a graph traversal source to these graphs on startup. Then you can directly execute Gremlin traversals on them. E.g., a graph named graph could get the traversal source g and then you can execute traversals via g.V().has([...]). A graph named gardengraph could get the traversal source g_garden so you could execute traversals via g_garden.V().... Creating the graph traversal sources for your graphs can happen in a groovy file. The server already comes with a default one: https://github.com/JanusGraph/janusgraph/blob/master/janusgraph-dist/src/assembly/static/scripts/empty-sample.groovy#L30 This Groovy script needs to be configured in your Gremlin Server YAML under scriptEngines.gremlin-groovy.plugins.org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin.files. For example like this: https://github.com/JanusGraph/janusgraph/blob/master/janusgraph-dist/src/assembly/static/conf/gremlin-server/gremlin-server-cql-es.yaml#L29
GitHub
janusgraph/janusgraph-dist/src/assembly/static/scripts/empty-sample...
JanusGraph: an open-source, distributed graph database - JanusGraph/janusgraph
GitHub
janusgraph/janusgraph-dist/src/assembly/static/conf/gremlin-server/...
JanusGraph: an open-source, distributed graph database - JanusGraph/janusgraph
Solution
Florian Hockmann
You then also don't need JanusGraphFactory.open() any more since JanusGraph Server already opened the graph instances for you. By using the JanusGraphFactory directly in Gremlin Console you basically circumvent this whole functionality from JanusGraph Server and instead access the JanusGraph API directly to load the graphs yourselves. This means that it doesn't know about your Gremlin Server YAML which also explains why you cannot use graph names defined in that YAML
Jamie Burns
Jamie Burns5mo ago
👍 Thank you