Vertex-level Access Control Functions
These functions are only available for vertex aliases (defined in the FROM clause of a SELECT statement); they cannot be applied to vertex variables in other contexts.
Function
Description
Return type
v.isTaggable()
Return true if v is of a taggable vertex type.
BOOL
v.getTags()
Return v's set of tags. If v is untaggable, it returns an empty set.
SET<STRING>
v.hasTags(
STRING tag1,... STRING tagN)
Return true if v has every tag in the argument list of tags.
BOOL
v.intersectTags(
VERTEX v2)
Return the set of tags that v and v2 have in common.
SET<STRING>
v.differenceTags(
VERTEX v2)
Return the set of tags that v has but v2 does not have.
SET<STRING>
v.addTags(
STRING tag1,... STRING tagN)
Add the given tags to v.
n/a
v.removeTags(
STRING tag1,...
STRING tagN)
Remove the given tags from v.
n/a
v.removeAllTags()
Remove all tags from V.
n/a
Security Roles: In order to use these functions, a user must have admin or designer roles on the base graph. These funcitons cannot be used on a tag-based graph.

isTaggable()

This function returns true if the vertex is taggable.

Example:

1
//count the number of taggable vertices in the graph.
2
CREATE QUERY countIstaggable() for graph poc_graph_tag {
3
SumAccum<int> @@count;
4
vSet = { any };
5
vSet = SELECT s
6
FROM vSet:s
7
WHERE s.isTaggable()
8
ACCUM @@count += 1;
9
PRINT @@count;
10
}
Copied!

getTags()

This function returns the vertex's tags as a set. If the vertex has no tags or is untaggable, it returns an empty set.

Example:

1
//print the tags of each vertices, in 2 different ways.
2
CREATE QUERY exampleGettags() {
3
SetAccum<string> @vAcc;
4
vSet = { any };
5
vSet = SELECT s
6
FROM vSet:s
7
ACCUM s.@vAcc += s.getTags();
8
PRINT vSet[vSet.@vAcc];
9
PRINT vSet[vSet.gettags()];
10
}
11
Copied!
Tip: getTags() can be used within a PRINT statement:
  • PRINT R [R.getTags()];
  • or PRINT R WITH TAGS which is syntax sugar, except that it won’t print "R.getTags()": [] for non-taggable vertices.

hasTags(STRING tag1,... STRING tagN)

This function returns true if the vertex has every tag provided in the argument list and returns false if it does not.

Example:

1
USE GRAPH socialNet
2
3
CREATE QUERY findVertexWithTag(STRING tag) {
4
seed = { ANY };
5
res =
6
SELECT v
7
FROM seed:v
8
WHERE v.hasTags(tag)
9
ORDER BY v.id;
10
PRINT res WITH TAGS;
11
}
12
13
INSTALL QUERY findVertexWithTag
14
15
RUN QUERY findVertexWithTag("vip")
Copied!
The output of the query would be:
1
{
2
"error": false,
3
"message": "",
4
"version": {
5
"schema": 2,
6
"edition": "enterprise",
7
"api": "v2"
8
},
9
"results": [{"res": [
10
{
11
"v_id": "person6",
12
"attributes": {
13
"gender": "Male",
14
"id": "person6",
15
"res.gettags()": [
16
"vip",
17
"public"
18
]
19
},
20
"v_type": "person"
21
},
22
{
23
"v_id": "person7",
24
"attributes": {
25
"gender": "Male",
26
"id": "person7",
27
"res.gettags()": [
28
"vip",
29
"public"
30
]
31
},
32
"v_type": "person"
33
},
34
{
35
"v_id": "person8",
36
"attributes": {
37
"gender": "Male",
38
"id": "person8",
39
"res.gettags()": ["vip"]
40
},
41
"v_type": "person"
42
}
43
]}]
44
}
Copied!

intersectTags(VERTEX v2)

This function returns the common tags between the vertex and another vertex as a set.

Example:

1
//return the intersect set of tags between two vertices.
2
CREATE QUERY exampleIntersecttags() {
3
SetAccum<string> @vAcc;
4
vSet = { any };
5
vSet = SELECT s
6
FROM vSet:s -(_)-> :t
7
WHERE t.type == "person"
8
ACCUM s.@vAcc += s.intersectTags(t);
9
PRINT vSet[vSet.@vAcc];
10
}
Copied!

differenceTags(VERTEX v2)

This function returns the difference in tags between the vertex and another vertex as a set.

Example:

1
//return the difference set of tags between two vertices
2
CREATE QUERY exampleDifferencetags() {
3
SetAccum<string> @vAcc;
4
vSet = { any };
5
vSet = SELECT s
6
FROM vSet:s -(_)-> :t
7
WHERE t.type == "person"
8
ACCUM s.@vAcc += s.differenceTags(t);
9
PRINT vSet[vSet.@vAcc];
10
}
Copied!

addTags(STRING tag1,... STRING tagN)

This function adds the tags provided in the argument list to the vertex.

Example:

1
CREATE QUERY addTagsToPerson() {
2
Seed = { any };
3
# person1 ~ person5 will be tagged as public.
4
vSet = SELECT s
5
FROM Seed:s
6
WHERE s.id IN ("person1","person2","person3","person4","person5")
7
ACCUM s.addTags("public");
8
9
# person6 and person7 will be tagged as public and vip.
10
vSet = SELECT s
11
FROM Seed:s
12
WHERE s.id IN ("person6","person7")
13
ACCUM s.addTags("vip", "public");
14
15
# person8 will be tagged as vip
16
vSet = SELECT s
17
FROM Seed:s
18
WHERE s.id == "person8"
19
ACCUM s.addTags("vip");
20
}
Copied!

removeTags(STRING tag1,... STRING tagN)

This function removes the tags provided in the argument list from the vertex.
1
//remove tagvipandpublicfrom all person vertices.
2
CREATE QUERY removetagsFromPerson() {
3
vSet = { person.* };
4
# remove tag vip and public from all person vertices
5
vSet = SELECT s
6
FROM vSet:s
7
ACCUM s.removeTags("vip", "public");
8
}
Copied!

removeAllTags()

This function removes all tags from the vertex.

Example:

1
//remove all tags from all person vertices.
2
CREATE QUERY removealltagsFromPerson() {
3
vSet = { person.* };
4
# remove all tags from all person vertices
5
vSet = SELECT s
6
FROM vSet:s
7
ACCUM s.removeAllTags();
8
}
Copied!
Last modified 4mo ago