Visual Query
In the graph editor, you can create graph query statements by dragging and dropping vertices and edges, and preview the query results without writing any code.
Procedure
- In the left pane of the graph editor, click the Visual Query tab.
Figure 1 Visual query
- Add a vertex to the canvas.
- In the Add Vertex Pattern tab, all vertex labels and edge labels of the graph are displayed. Each label is displayed as a card that can be dragged to the canvas. Select a vertex label and drag it to the canvas.
The Cypher query statement below changes with your operations.
These vertex labels and edge labels are the same as those in the metadata list in Editing Schema.
- Drag the labels you want to use for the query to the canvas and click Execute Query. The graph result is displayed on the right of the canvas.
You can view the running records of the Cypher query statement in the Running Record tab below the canvas. Click Query Result to view the result.Figure 2 Query result
Query results can be displayed only when there is only one submap pattern on the canvas. If there are multiple disconnected submaps or isolated vertices, you must add edges to connect the submaps or isolated vertices. You can also set multiple labels to reconstruct your query mode. Otherwise, when you click Query, the system displays a message indicating that there are multiple submap patterns.Figure 3 Multiple submap patterns
- In the Add Vertex Pattern tab, all vertex labels and edge labels of the graph are displayed. Each label is displayed as a card that can be dragged to the canvas. Select a vertex label and drag it to the canvas.
- Add a vertex filter.
Click a vertex in the canvas. The Filter tab page is displayed in the left pane. On the Filter tab, specify labels, vertex ID, and property search criteria to search for the vertex labels you want to view on the canvas.Figure 4 Adding a vertex search criterion
- Vertex V1: Cypher variable ID (vertex identifier in the Cypher query statement below the canvas), which is named based on the sequence in which vertices are dragged to the canvas, for example, V1, V2, and more alike.
- Label: Set one or more labels to search for target vertices. The logical operator between each two labels is OR.
- Vertex ID: It is equivalent to a filter criterion. After adding a vertex ID to a vertex label, you can click Query to query the vertex labels with the same vertex ID.
- Constraints: Specify a property contained in the vertex label. Currently, a property with multiple values is not supported.
- Property: Property contained in the label.
- Operator: Comparison operators (>,>=,<,<=,=,<>), null judgment operators (is null, is not null), and string comparison operators (starts with, ends with, contains) are supported.
starts with searches for a property that starts with a specified string; ends with searches for a property that ends with a specified string; contains searches for a property that contains a specified string.
- Value: Property value. The attribute value type must be the same as that in the metadata. If the attribute value is of the character type, you need to use single quotation marks ('').
- : Delete the constraint.
- + button: Add a criterion.
- Delete: Delete the added criterion.
Click Execute Query in the canvas again. The query result is displayed on the right of the canvas.
- Add an edge (connect two vertices on the canvas):
Double-click a vertex. After the border of the vertex turns red (do not move the cursor out of the red border), click and drag a line from the vertex to another vertex.
The Cypher query statement below changes with your operations.
Figure 5 Red border of a vertex
Figure 6 Adding an edge
- Add an edge filter.
Click an edge in the canvas. The Filter tab page is displayed in the left pane. On the Filter tab, specify labels, direction, hops, and property search criteria to search for the edge labels you want to view on the canvas.
Figure 7 Adding an edge filter
- Edge e2: Cypher variable ID, which is named based on the sequence in which edges are added to the canvas, for example, e1, e2, and more alike.
- Label: Set one or more labels to search for target edges. The logical operator between each two labels is OR.
- Direction: Select the direction contained in the edge label.
When the slider is toggled on, the edge is a directed one. When the slider is toggled off, the edge is undirected (or called bidirectional).
If the edge is directed, the arrow on the canvas indicates the direction of the edge. You can click Change Direction to change the direction of the selected edge on the canvas.
- Hops: The default value is 1. The value range is [0, 20). You can specify a number or a range.
- If you enter an integer, it will be used as the number of hops in the edge pattern.
- If you enter two integers in the format of minHops..maxHops, for example, 2..3, the number of hops in the edge pattern is within the range of [2,3].
- Constraints: Specify a property contained in the edge label. Currently, a property with multiple values is not supported.
- Property: Property contained in the label.
- Operator: Comparison operators (>,>=,<,<=,=,<>), null judgment operators (is null, is not null), and string comparison operators (starts with, ends with, contains) are supported.
starts with searches for a property that starts with a specified string; ends with searches for a property that ends with a specified string; contains searches for a property that contains a specified string.
- Value: Property value. The attribute value type must be the same as that in the metadata. If the attribute value is of the character type, you need to use single quotation marks ('').
- : Delete the constraint.
- + button: Add a criterion.
If there is more than one criterion, click next to AND to set the logical operator (AND or OR).
Figure 8 Selecting a logical operator
The priority of AND is higher than OR. The suggested calculation sequence is as follows:
- Arrange all AND operations first.
- Then, perform all OR operations.
In the following example, the edge search criterion is userid < 100 AND gender = 'male' OR userid > 50 AND age = '18-24'.
The operation sequence is:
(userid < 100 AND gender = 'male') and (userid > 50 AND age = '18-24') are operated first, and result1 and result2 are recorded respectively.
Then, result1 OR result2 is operated.
- Delete: Delete the added criterion.
Click Execute Query in the canvas again. The query result is displayed on the right of the canvas.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.