5.1.2 Label Expressions
A label expression in a vertex or an edge element pattern is introduced by
the keyword IS
.
For example, in the following graph pattern, the vertex pattern associated with the
graph element variable v1
has the label person
.
Also, the edge pattern associated with the graph element variable
e
contains the label friendOf
:
(v1 IS person)–[e IS friendOf]->(v2)
If the label is omitted in a graph element pattern, then the default is to query all vertices or edges.
A label expression can also include an optional in-line SQL search condition that can access any matched variable. When accessing a property, you must specify a graph pattern variable.
The supported vertex and edge label expressions are described in the following table:
Table 5-2 Supported Vertex and Edge Label Expressions
Vertex Label Expression | Edge Label Expression | Description |
---|---|---|
(a) |
[e] |
|
() |
[] |
When a graph pattern variable is not specified, a unique vertex or edge variable name is internally generated by the system. Therefore, you cannot reference the vertex or edge elsewhere in the query, as it is unknown. |
(IS person) |
[IS friend_of] |
When a graph pattern variable is not specified, a unique vertex or edge variable name is internally generated by the system. Therefore, you cannot reference the vertex or edge elsewhere in the query, as it is unknown. |
(IS person|place|thing) |
[IS friend_of|student_of] |
As there is no explicit graph pattern variable in the vertex or edge pattern, you cannot reference this vertex or edge elsewhere in the query. |
(a IS person|place|thing) |
[e IS friend_of|student_of] |
Same as the preceding table entry. However, the
vertex and edge patterns contain a and
e as vertex and edge graph pattern variables
respectively. Therefore, you can reference the vertex or edge using
the respective graph pattern variables elsewhere in the query.
See Example 5-12. |
(a IS person),
|
(a)–[e IS L1]->(b),
|
See Example 5-13. |
(a IS person WHERE a.name =
'Fred') |
[e IS student_of WHERE e.subject =
'Arts'] |
The only graph pattern variable that is visible within an element pattern is the graph pattern variable defined locally by the element pattern. Graph pattern variables from another element patterns cannot be accessed. See Example 5-5. |
Parent topic: About Graph Pattern