As of September 2019, Compose will soon no longer support JanusGraph on the platform. Provisioning of new JanusGraph deployments is disabled.
Exploring your graph data from the command line can be a complex task. For beginners and initial data exploration, there can be difficulty in forming your traversals on the command line. When you get results, it can often be hard to convert the the text outputs into digestible graph relationships. This where the Browser for JanusGraph on Compose comes in.
Browser for Compose JanusGraph combines an easy to use Query Builder with rich Query Response Cards which stack up below the builder. Each card records the query and displays the results as an interactive JSON view and as a visualized graph which can be explored, relative to the JSON view. Each card can help you refine your next query.
The link to the Browser is located on the browser tab of your JanusGraph deployment. Clicking on Open will load the interface into a new tab.
Enabling the Browser
This is a view of the browser after a first query has been run.
At the top (1) is the Query Builder where queries are created, edited and executed.
Below the Query Builder (2) is a Query Response card. New cards are inserted at the top of the card stack. The previous top card was (3) the interactive introduction to the browser. This appears whenever you start the browser.
The Query Builder is a simple multi-line editor with syntax highlighting to assist in the composition of Gremlin scripts.
Each query generates a response card that contains your query, a JSON response and, if available, a graph visualization of the query results.
The top of each card displays the query that was run(1), and three options:
- (2) A copy button.
- (3) Collapse/Expand button.
- (4) A close button.
As you run more queries, each will get it's own response card, with newest response cards at the top pushing the previous ones down the page. If the page gets long, or you notice decresed performance, you can use the Collapse button to save some frames. If you no longer need the results on a card, you can close it completely. Closing a response card will not delete any data in the graph.
The JSON viewer is a syntax-highlighted text view of the response. Lines are numbered for easier navigation through the results. Where the JSON document is nested, small arrows are displayed. These can be clicked to fold up the nested section which then appears
The JSON view also has filters that can be applied to manage how much information is displayed. The filters are selected by clicking on the Label, Type and Properties buttons. More than one button can be selected. Here is an example of the filters in action:
If your query result can be visualized, the card will display a graph with vertices and edges. You can click on the vertices to see their properties. Click and drag the vertices to move them around and lock them into position.
def g=ConfiguredGraphFactory.open("example").traversal(); g.V().has(T.label, "god");
produces the following response card with a visualization, showing all the vertices in the graph that represent the gods:
For a more interesting example:
def g=ConfiguredGraphFactory.open("example").traversal(); g.V().has(T.label, "god").outE().inV().path();
shows all the edges leading out from the gods vertices; and the vertices that those edges go in to.
The visualizer only renders what is in the JSON results on the left, so only the returned vertices and edges are shown. That's why, if you just query for vertices you just get a set of unconnected nodes appear in the visualization as there are no edges to connect them. There are a number of ways to populate the results with edges. A simple but powerful one is the
path() function. This, when added to a Gremlin query, asks for the route taken to get to the vertices in the graph to be included. If the route traverses only vertices, then only vertices are returned, but if it includes edges, these are included in the results. The Gremlin documentation on path-step has more on the
def g=ConfiguredGraphFactory.open("example").traversal(); g.V().outE().inV()
def g=ConfiguredGraphFactory.open("example").traversal(); g.V().outE().inV().path()
Some commands in the browser can return a
nullresult. This is typically because the value they return is not, currently, serializable. The most common example of that is any command or expression which returns a graph, including the
createmethods. Extend your command to return vertices and edges; although null is displayed, the actual values are intact within JanusGraph and are available to use in a query.
If this article didn't solve things, summon a human and get some help!
Updated almost 3 years ago