Query Editor
Run your Query
To run your query, simply click on . G.V() will attempt to run your query against your server, and display the results window indicating the output of your query. More information is available at Results View.
You can have multiple queries specified in the same Query Editor. If there is more than one query in your editor, clicking on Run Query will run the query nearest to your mouse cursor. You can easily swap between queries to run by clicking on the query you would like to run before running it.
WARNING
When running your query, remember to specify a terminal step (e.g. toList, next, iterate). If not specified, G.V() will automatically use the .toList() step to your query.
Error Management
Using Apache TinkerPop™'s ANTLR grammar, G.V() will attempt to proactively warn of any syntax errors in your query. Syntax errors in your query are highlighted in the code editor and listed below it. Note that at this moment, G.V() will not warn of any semantic errors (e.g. using the select step with an unknown select key), but will in future versions.
Autocomplete Features
Using Apache TinkerPop™'s ANTLR grammar, G.V() will provide smart autocomplete suggestions as you're typing your query. Additionally, G.V() loads the structure of your graph data in the background and will make suggestions on Edge, Vertex and Property labels.
For Cypher/openCypher users, G.V() provides the exact same level of autocomplete suggestions.
Translate a Query to a target Gremlin Language Variant
To translate your query directly to a target Gremlin Language Variant (GLV), click on and select your target language in the resulting modal window. Note that if there are any syntax errors in your query, this feature will be unavailable. This feature is only available for the Gremlin query language.
Debug Query
For more details, go to the Gremlin Query Debugging documentation. This feature is only available for the Gremlin query language.
Formatting using Gremlint
To format your query using Gremlint, click on . This feature is only available for the Gremlin query language.
Fetch All Edges Between Vertices
By default, when only fetching vertices from your Gremlin Server, the resulting graph visualisation will not include any edges. Toggling on will cause all edges found between resulting vertices to also be returned, allowing for a more useful graph visualisation experience. This is equivalent to adding the .bothE() step to your graph traversal when it returns vertices.
Fetch Vertex Meta Properties
By default, when fetching vertices, only direct properties will be returned by your Gremlin Server. For convenience purposes, toggling on will automatically append any meta properties on vertices returned by your query. Note that this is modifying the results of your query and therefore doesn't represent the effective response returned by Gremlin Server, but it allows to quickly visualize the entire data appended to your vertices. This feature is only available for the Gremlin query language.
Console Mode / Groovy Mode
This feature is only available for the Gremlin query language. If enabled, submits your query as a script using Gremlin Client as opposed to running it as bytecode.
This is primarily useful to submit scripts that aren't Gremlin queries (e.g. JanusGraph Schema Management commands). This may also be useful in situations where your server implementation contains custom code that doesn't bundle with the default Apache TinkerPop code, to prevent serialisation issues. This may also be required to submit complex lambdas. This option is off by default and can be toggled by clicking on .
In Console Mode, G.V() will not attempt to parse the results beyond just their console output. In Groovy Mode, G.V() will still parse the output as it would for a regular query, meaning this can be used to output a Graph display. Groovy Mode is intended for users that need to run complex scripts with functions whilst needing the full output display that G.V() offers for query results.
TIP
This option is not applicable to Azure Cosmos DB/Azure Cosmos DB Emulator which does not support Bytecode, nor G.V()'s Playground where custom code/serialization is not applicable. Amazon Neptune also does not need this feature as you custom groovy scripts cannot be submitted to their Gremlin endpoint.
TIP
When using Console Mode or Groovy Mode, autocomplete features and syntax checking are both disabled as G.V() does not support autocomplete for provider specific server language feature (e.g. JanusGraph Schema Management API).
Query Timeout
Located at the bottom of the query editor, this feature allows you to specify a time limit for your query. The default timeout is 30,000 milliseconds. You can disable the timeout by setting it to 0.
WARNING
This feature is not available for Azure Cosmos DB and G.V() Playground as they do not support user specified timeouts.
Default Results Tab
Located at the bottom right of the query editor, this option allows you to choose which Output tab to default to once the query is run. If the query you're running does not output a result that satisfies the conditions of the default results tab, it will default to the Query Output. The output tab options are:
- Default (automatically detects which output tab to use)
- Graph (Legacy) View
- Graph View
- Vertex View
- Edge View
- Profile View
- Traversal Explanation
View Query History
To view previous queries run in your query editor, click on . The query history view allows you to navigate previously run queries.
Toggle Editor Autocomplete Suggestions
Autocomplete popups can be dismissed by pressing the Escape key or clicking away from them. Alternatively, they can be enabled/disabled on an editor by clicking on . The default value for this setting when opening a new query editor is determined by the Enable Query Editor Smart Autocomplete setting in the Application Settings.
Keyboard Shortcuts
The following keyboard shortcuts are currently available on the query editor:
- Ctrl/Cmd+F: Format Query
- Ctrl/Cmd-S: Save Query
- Ctrl/Cmd-W: Close Query
- Alt+Enter: Submit Query
- Ctrl/Cmd+T: Translate Query
- Ctrl/Cmd+F: Find
- Ctrl/Cmd+Space: Toggle Autocomplete
- Escape: Close Autocomplete Window
- Ctrl/Cmd+Slash: Toggle Comment Current Line or Selected Lines
- Ctrl+F5/Shift+Cmd+F5: Toggle Debugging (More debugging shortcuts here)
You can view the currently available keyboard shortcuts by clicking 'View Keyboard Shortcuts' from the Query Assistant side menu.
Save a Query
To save your query, click on . If you haven't previously saved your query, you will also be prompted to specify a name for it. If your query can be saved, this will be signified by a * displayed next to the query's name.
When saving a query, all of the settings and variables set on the query will also be saved, this includes the value of:
- Fetch All Edges Between Vertices
- Fetch Vertex Meta Properties
- Console Mode
- Default Results Tab
TIP
G.V() will automatically remember all the queries you've previously opened. You can safely close G.V() and return to your queries when you next re-open the application.
Organize your Queries Into Folders
G.V() allows you to organize your queries into folders. You can manage folders from the Connection side menu. From there, you can perform the following folder actions:
- Create a new folder
- Delete a folder
- Move a folder into another
- Move a query to a folder
Additionally when saving a query, you will be given the option to choose a folder to save the query to.
Text to Gremlin
This feature is only available for the Gremlin query language.
G.V() offers an experimental OpenAI integration that allows generating Gremlin queries via the OpenAI API.
The prompt G.V() sends to the OpenAI API contains details of your graph database's data model to give it the best chance of generating a Gremlin query that will work for your graph database.
It is therefore important to understand first and foremost that when using this feature, you will be sending details of the structure of your data to the OpenAI API, but not any of the data itself contained within your database itself.
For a reference of what information is generated as part of G.V()'s data model, please refer to the Data Model Management documentation.
When converting a text prompt to a Gremlin Query, you will be offered two options:
- OpenAI Prompt: The text prompt to send to the OpenAI API to be converted to a Gremlin query.
- Query Output Format: The output format for the query that the OpenAI API will generate. Currently can be set to Raw, which lets the OpenAI API decide on the appropriate format to use, of Graph, which adds additional information in the prompt to force the OpenAI API to generate a query that will output in a format that leads to a graph visualisation in G.V().
TIP
This is an experimental feature. OpenAI is an evolving tool that is getting increasingly better at generating accurate Gremlin queries, but will not always get it right. If a generated query does not meet the criteria of your prompt, try and make your prompt more detailed.
TIP
The OpenAI API will have information of your graph's data model and therefore understand language that is derivative or synonym to the labels and property keys available in your graph database. Your prompt should include keywords that match your graph database's labels and property keys. Here are some examples of prompts:
- get all countries with at least 50 airports
- show all payments made to account 0008-7960-9302-7255 and the merchants for the transactions
- show all payments made to account 0008-7960-9302-7255 and the ip addresses in the transactions
Query Variables
Setting Query Variables for Gremlin
You can set variables in your Gremlin Query to allow running reports against your databases based on simple configurable prompts. Query variables can be entered instead of any parameter to any step in your query. The naming convention for variables is as follows:
{{ variable_name }}
TIP
Variable tags should not be enclosed in quotes as they will otherwise not be recognized. If your variable value should be enclosed in quotes, you can either enter its value between quotes OR toggle the "Enclose In Quotes" option.
When you enter add a variable to your query it will then automatically display in the Gremlin Query Assistant on the right handside of the query editor. Your query can have as many variables as it needs and you can enter the same variable names in multiple places. See below an example of a query with variables:
g.V().
has('code', {{ source_airport }}).
repeat(outE().inV().simplePath()).until(has('code', {{ target_airport }})).
path().
limit({{ maximum_paths }})
This query contains three variables:
- source_airport
- target_airport
- maximum_paths
Setting Query Variables for Cypher
G.V() supports the native parameters terminology of the Cypher language. When entering a parameter in your query (e.g. $my_param), G.V() will automatically detect it and prompt you to enter a value for the parameter.
The variables can then be configured from the Gremlin Query Assistant, as shown below:
When entering a value for your variable, G.V() will replace the variable tag with the value you've specified as is. You can set the variable value to be enclosed in quotes by clicking (instead of entering the value including quotes). There are multiple additional settings you can set on your variable by clicking on . You'll be presented with two more options:
- Default variable value: the value the variable should be set to if no value is specified when running the saved query as a report.
- Variable label: the label to be displayed above the variable's input when running the saved query as a report. Both options above are meant to customize the report running experience for users you may deploy the report to.
Looking back at our example above, we will use the following configuration and values:
- source_airport, Enclose in Quotes enabled, value: JFK
- target_airport, Enclose in Quotes enabled, value: GLA
- maximum_paths, Enclose in Quotes disabled, value 5
This will result in the following query being run:
g.V().
has('code', "JFK").
repeat(outE().inV().simplePath()).until(has('code', "GLA")).
path().
limit(5)
When saving your query, your variable settings will also be saved and made available to other users of your database wishing to run the query.
Running a Report
If you have saved a query, you can then choose to run it as a report. To run a query as a report, select Run Query from the dropdown of options on your saved query in the connection sidebar, as shown below:
If your query contains no variables, it will immediately run and display the output in fullscreen mode. Otherwise, you will be prompted to enter the query variables' values. Looking back at our previous example, we get the following prompt:
Once you fill in the variable values (or use the default values, if available), click on Run Query to view the report results. In our example above, this next screenshot shows a sample result against our dataset for source_airport=GLA, target_airport=JFK and maximum_paths=5:
You can open any number of report tabs for the same query, or you can edit and re-run your report by clicking on "Edit Report Parameters".