Visual Query¶
The Visual Query feature uses a visual representation to express related requests. It allows you to create query scenarios to look up the desired data and view the corresponding statements. You can construct visual query statements by simply dragging and dropping, and then the system displays the query results on the query panel.
Compatibility
The Visual Query feature is not compatible with NebulaGraph versions below 3.0.0.
Note
Currently, the Visual Query feature is still in beta.
Prerequisite¶
- You have choosen a graph space. For details, see Choose graph spaces.
- You have created indexes for particular queries. For details, see MATCH precautions and CREATE INDEX.
Page elements¶
At the top of the Explorer page, click Visual Query to enter the visual query page. On the left side of the Visual Query page, all the Tag(s) corresponding to the graph space (e.g.player and team) and the Tag named Any Tag are displayed. You can query vertices without tags by the Tag named Any Tag.
Note
Any Tag can also be used to query the vertex without tags.
On the page, the descriptions of other icons are as follows.
Icon/Element | Description |
---|---|
The selected vertices and edges are the results to be queried. Double-click on the query pattern frame to limit the number of queries (with a priority higher than the value of the maximum number of returns in the global settings). Only querying edges is not supported. | |
Zoom in on the query page. | |
Zoom out on the query page. | |
Save the current query graph. The saved graph is cached in the browser. | |
View all stored query graphs. Up to 10 recently saved visual graphs are displayed. Click any of the stored graphs to display them on the visual query page. | |
nGQL | Click nGQL to view the statement corresponding to the query pattern. |
Run Query | Click Run Query to display the query results visually on the canvas. |
Steps¶
-
Drag several target tags from the left side of the Visual Query page to the canvas to create the corresponding vertices.
-
Click a vertex, hold down the left mouse button on the anchor point at the edge of the vertex, and drag it to another vertex to create the corresponding edge.
-
Set a vertex by clicking it. The descriptions of configuration options are as follows.
- Tag Name: Set zero, one, or multiple tags.
Note
One vertex can have zero or multiple tags:
- When 0 tag is set, query the vertex without tags.
- When 1 tag is set, query the vertex with that tag.
- When multiple tags are set, query the vertex that has all the tags you set.
- Filter: Add one or more sets of filter conditions, including vertex properties, operators, and property values.
Note
When setting multiple tags in the Tag Name dialog box, it is not supported to set filter conditions to query data.
-
Set an edge by clicking. The descriptions configuration options are as follows.
- Edge Type: Set one or multiple edge types.
Note
One edge have one and only one edge type:
- When one edge type is set, query the edge with that edge type.
- When multiple edge types are set, query the edge that has any of the edge types you set.
- Direction: Set the edge direction between two vertices, including Outgoing, Incoming, and Bidirect.
- Single: Set a fixed-length path.
- Range: Set a variable-length.
- Filter: Add one or more sets of filter conditions, including edge properties, operators, and property values.
Note
When setting multiple edge types in the Edge Type dialog box, it is not supported to set filter conditions to query data.
-
After the query scenarios (pattern) is created, click and select the result you want to return.
-
Click Run Query on the upper right corner of the Visual Query page to display the query results on the canvas.
Examples¶
Example 1¶
Find out players who follow each other with Yao Ming and older than 35, and which teams these players are loyal to, and limit the number of the query patterns of the players and teams to 6.
-
Create a query pattern by dragging and dropping Tags to the panel (2 players and 1 team).
-
Configure filter conditions.
- Set the filter condition for the first player to
player.name == Yao Ming
. - Set the edge type of the edge between the first and second vertices of the tag player to
follow
, set the direction toBidirect
, and the steps to1
. - Set the filter condition for the second player to
player.age > 35
. - Set the edge type of the edge between the second player and the team to
serve
, the direction toOutgoing
, and the steps to1
. - Click to select the second player, the team, and the serve edge between them.
- Click the Query Pattern frame, and set the Limit Number to
6
.
- Set the filter condition for the first player to
-
Click Run Query, and the system displays 6 query patterns on the canvas.
Example 2¶
Find out what teams two mutually-following players are loyal to and query for all players on that team who are older than 30.
- Create a query pattern by dragging and dropping Tags to the panel (3 players and 1 team).
-
Configure filter conditions.
- Set the edge type of the edge between the first and second players to
follow
, set the direction toBidirect
, and the steps to1
. - Set the edge type of the edge between the first player and the team to
serve
, the direction toOutgoing
, and the steps to1
. - Set the edge type of the edge between the second player and the team to
serve
, the direction toOutgoing
, and the steps to1
. - Set the filter conditions for the third player to
player.age > 30
. - Set the edge type of the edge between the third player and the team to
serve
, the direction toOutgoing
, and the steps to1
. - Click to select the third player, the team, and the serve edge between them.
- Set the edge type of the edge between the first and second players to
-
Click Run Query.