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:
-
Use the keyword
OPENCYPHERto specify the query type when youCREATEorINTERPRETa query:-
INTERPRET OPENCYPHER QUERY -
CREATE OPENCYPHER QUERY
-
-
Replace the body of the query procedure with OpenCypher instead of GSQL. End with a
RETURNclause.
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
-
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.
-
Install the query.
INSTALL QUERY get_user_by_id2 -
Run the installed query.
RUN QUERY get_user_by_id2()Note that you don’t need to specify
OPENCYPHERwhen you install or run the query. In particular,INSTALL QUERY ALLwill work on a combination of GSQL and openCypher queries.