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.
This tutorial was updated for TigerGraph 3.0. If you are using an older version, please change to the documentation for that version.
What is a Graph Pattern?
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
What is Pattern Matching?
Pattern matching is the process of finding subgraphs in a data graph that conform to a given query pattern.
Prepare Your TigerGraph Environment
We assume you are running your own TigerGraph instance 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.
Type gsql as below. A GSQL shell prompt should appear as below.