Get Set

Introduction

In this tutorial, we will show you how to write and run Pattern Matching queries.

We assume you have finished GSQL 101. If not, please complete GSQL 101 first.

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 privileges on an empty graph.

At various points in this tutorial, there are links to download files. Most are small, but note that 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.

  1. Open a Linux shell.

  2. Type gsql as below. A GSQL shell prompt should appear as below.

  3. Type version in GSQL shell. It should show 2.4 or higher as below. If not, please download and install the latest version from https://www.tigergraph.com/download/

    Linux Shell
    $ gsql
    GSQL > version
    GSQL version: 3.0
  4. If the GSQL shell does not launch, try resetting the system with "gadmin start all". This will launch each service if they have not been started yet. If you need further help, please see the documentation on managing TigerGraph with gadmin.

  5. You need to start from an empty data catalog. If necessary, run drop all to clear the catalog first.

Cheatsheet

The following general use commands were introduced in GSQL 101.

  • The % prefix indicates Linux shell commands. You need TigerGraph admin privileges to run most gadmin commands.

  • The GSQL> prefix indicates GSQL shell commands.

Command Description

% gsql

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

GSQL> ls

List the graph schema, loading jobs, and queries

GSQL> show user

Show your username and roles

GSQL> drop all

Delete the entire schema, all data, all jobs, and all queries

GSQL> exit

Exit GSQL interactive shell