In this tutorial, we will show you how to write and run Pattern Matching queries. Pattern Matching is available in TigerGraph v2.4+.
We assume you have finished GSQL 101. If not, please complete GSQL 101 first.
A graph pattern is a traversal trace on the graph schema. A pattern can contain repeated steps. A pattern can be a linear trace, or a non-linear trace (tree, circle etc.). For example, imagine a simple schema consisting of a Person vertex type and a Friendship edge type. A pattern could be a trace on this simple schema,
Person - (Friendship) - Person - (Friendship) - Person
or, use *2 to denote the two consecutive Friendship edges,
Person - (Friendship*2) - Person
Pattern matching is the process of finding subgraphs in a data graph that conform to a given query pattern.
We assume you are running Developer Edition as the sole user with full privileges. If you are on a multiuser Enterprise Edition, consult with your DB administrator. You need to have Designer or Admin privilege on an empty graph. At various points in this tutorial, there are links to download files. Most are small, but the graph data file is 1GB when uncompressed.
First, let's check that you can access GSQL, and that your version is 3.0 or higher.
Open a Linux shell.
gsql as below. A GSQL shell prompt should appear as below.
Type version in GSQL shell. It should show 2.4 or higher as below. If not, please download and install the latest developer version from https://www.tigergraph.com/download/
Linux Shell$ gsqlGSQL > versionGSQL version: 3.0
You need to start from an empty data catalog. If necessary, run
drop all to clear the catalog first.
The following general use commands were introduced in GSQL 101.
% prefix indicates Linux shell commands. You need TigerGraph admin privilege to run most gadmin commands.
GSQL> prefix indicates GSQL shell commands.
Enter the GSQL shell in interactive mode
% gsql '<GSQL command string>'
Run one GSQL command
% gadmin status
Check the status of TigerGraph services (If your graph store is empty, it is normal for some statuses to be flagged in red.)
% gadmin restart
Restart TigerGraph services
List the graph schema, loading jobs, and queries
GSQL> show user
Show your user name and roles
GSQL> drop all
Delete the entire schema, all data, all
jobs, and all queries
Exit GSQL interactive shell