Writing and Running openCypher in GSQL Shell

You can run openCypher queries in a GSQL shell, e.g., a GSQL Web Shell from TigerGraph Cloud.

OpenCypher queries run the same way that GSQL queries do, either as anonymous interpreted procedures or as installed named procedures.

Follow these two simple rules:

  1. Use the keyword OPENCYPHER to specify the query type when you CREATE or INTERPRET a query:

    • INTERPRET OPENCYPHER QUERY

    • CREATE OPENCYPHER QUERY

  2. Replace the body of the query procedure with OpenCypher instead of GSQL. End with a RETURN clause.

For more details on the current openCypher support, see openCypher in GSQL.

Example: Interpreted Query

INTERPRET OPENCYPHER QUERY () FOR GRAPH communication_mau {
MATCH (u:user)
WHERE u.id = "test"
RETURN u
}
INTERPRET QUERY does not support DISTRIBUTED query mode.

Example: Installed Query

  1. Create an openCypher query.

    CREATE DISTRIBUTED OPENCYPHER QUERY get_user_by_id2() FOR GRAPH communication_mau {
    MATCH (u:user)
    WHERE u.id = "test"
    RETURN u
    }

    Note that the query body is the same when creating or interpreting a query. Only the header changed.

  2. Install the query.

    INSTALL QUERY get_user_by_id2
  3. Run the installed query.

    RUN QUERY get_user_by_id2()

    Note that you don’t need to specify OPENCYPHER when you install or run the query. In particular, INSTALL QUERY ALL will work on a combination of GSQL and openCypher queries.