As for the tutorial with usages of alias, I recommended looking at this one. It’ll also go in more details over how you can utilize different elements of a 1-hop traversal pattern (like filtering): One-hop patterns :: GSQL Language Reference
The :e
and :t
are alias that can be used to refer to the the edge and the target vertex. Generally, I used the “e” alias for edge, and the “t” alias for “target”. There’s no definite rules around this - you can use any alias/names to refer to the source, edge, and target that makes sense to you.
Basically, what this query
SELECT t FROM start_person:p -(:e)- :t;
means is, it’ll start from start_person vertex/vertices, go to every edge of start_person (any edge type), and from that reaches out to every target vertex (any vertex type).
If you want to specify the type of vertex, you can also do it like below, where it’ll reach out the target vertex of type “Person” or “School”.
SELECT t FROM start_person:p -(:e)- (Person|School):t;
We didn’t get to use e
and t
alias yet in the above pattern, I just use it so we know which part is an edge and which part is a target. Aliases could be helpful when you do the filtering and gathering information. For instance, suppose you want to gather information about the school names and how they are connected to a person, you can use an accumulator and print the results out.
CREATE QUERY get_all_school_connections_to_person(VERTEX<Person> p) FOR GRAPH <graph-name-here> {
ListAccum<EDGE> @@edge_list;
SetAccum<STRING> @@school_name_list;
start_person = {p};
all_1_hop = SELECT t FROM start_person:p -(:e)- School:t
ACCUM
@@edge_list += e,
@@school_name_list += t.name;
PRINT all_1_hop;
PRINT @@school_name_list;
PRINT @@edge_list;
}
If you print out the edges, the “visualize graph result” tab would show the shape of the connections! See here for details: Write Queries :: GraphStudio and Admin Portal
You can read more information about the accumulator here: Accumulators Tutorial :: GSQL Language Reference
I hope this helps!
Best,
Supawish Limprasert (Jim)