Executing GQL Queries
Function
GQL is a declarative query language with its core syntax resembling Cypher. Use GQL to query data in GES and retrieve results. For detailed information on GQL queries, refer to GQL Syntax.
URI
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Project ID, which is used for resource isolation. For how to obtain a project ID, see Obtaining a Project ID. |
graph_name |
Yes |
String |
Graph name |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
statements |
Yes |
List |
Statement group that contains one or more statements. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
statement |
Yes |
String |
GQL statement |
parameters |
No |
Json |
GQL statement parameters, which are used for parameterized queries. This parameter is left blank by default. For details, see parameterized queries. |
resultDataContents |
No |
String or List |
Format of the execution results. You can set one or more formats. The options are row, graph, and raw. |
includeStats |
No |
Boolean |
Whether the returned result contains addition, deletion, and modification statistics. If this parameter is not set, the returned result does not contain the information by default. |
runtime |
No |
String |
Executor type. The default value is block. |
executionMode |
No |
String |
Execution mode. Set this parameter to sync for synchronous execution and to async for asynchronous execution. If this parameter is not set, the execution is synchronous by default. For how to obtain the query results in asynchronous mode, refer to section 5.10.1. |
limit |
No |
Integer |
Maximum number of asynchronous results. This parameter applies only when executionMode is async. The default value is 100000. |

- You can add the explain or profile prefix before a statement to display the query plan. The explain prefix displays only the query plan but does not execute the statement. The profile prefix displays the query plan and executes the statement.
- In asynchronous mode (executionMode is async), GQL query results of the memory edition can be exported to CSV files. This edition currently allows returning the following value types: vertex and edge single-value properties, vertex and edge IDs, and group count results. Object types cannot be exported in the current version. They are treated as null values in CSV files. For more details, refer to Exporting Job Execution Results to Files (2.2.1).
Response Parameters
Parameter |
Type |
Description |
---|---|---|
results |
List |
Each element is the return result of a GQL statement. For details about the parameters, see Table 5. |
errors |
List |
Each element contains the code and message information in string form. |
Parameter |
Type |
Description |
---|---|---|
columns |
List |
Name of a returned field |
data |
List |
Returned data value. Each element indicates a record. For detailed parameter descriptions, refer to Table 6. |
stats |
Json |
Returned statistics about addition, deletion, and modification operations. For detailed descriptions, refer to Table 7. |
plan |
Json |
If the GQL statement contains the explain or profile prefix, this field contains the query plan. Otherwise, this field is not displayed. |
jobId |
String |
Asynchronous job ID if the request is executed asynchronously |
jobType |
Integer |
Type of the asynchronous job if the request is executed asynchronously |
Parameter |
Type |
Description |
---|---|---|
row |
List |
Content of a specific row. Each element corresponds to a field in the row. This parameter is displayed only when resultDataContents is empty or contains row. |
meta |
List |
Type of each field in a row. This parameter is displayed only when resultDataContents is empty or contains row. |
graph |
Json |
Information returned in graph format. This parameter is displayed only when resultDataContents contains graph. |
raw |
List |
Content of a specific row. Each element corresponds to a field in the row. This parameter is displayed only when resultDataContents contains raw. |
Parameter |
Type |
Description |
---|---|---|
contains_updates |
Boolean |
Whether data is modified during the query |
edges_created |
Integer |
Number of created edges |
edges_deleted |
Integer |
Number of deleted edges |
labels_set |
Integer |
Number of labels that have been set |
properties_set |
Integer |
Number of properties that have been set |
vertices_created |
Integer |
Number of created vertices |
vertices_deleted |
Integer |
Number of deleted vertices |
Example Request
POST http://{SERVER_URL}/ges/v1.0/{project_id}/graphs/{graph_name}/action?action_id=execute-gql-query { "statements": [{ "statement": "match (n) return n limit 1", "runtime":"block", "parameters": {}, "resultDataContents": ["raw"] }], "includeStats": true }
Example Response
- Example response for a successful synchronous request
Http Status Code: 200 { "results": [ { "columns": ["n"], "data": [ { "row": [ { "occupation": "artist", "gender": "F", "Zip-code": "98133", "userid": 0, "age": "25-34" } ], "meta": [ { "id": "46", "type": "node", "labels": [ "user" ] } ] } ], "stats": { "contains_updates": false, "edges_created": 0, "edges_deleted": 0, "labels_set": 0, "properties_set": 0, "vertices_created": 0, "vertices_deleted": 0 } } ], "errors": [] }
- Example response for a successful asynchronous request
Http Status Code: 200 { "results": [ { "columns": ["n"], "data": [ { "row": [ { "occupation": "artist", "gender": "F", "Zip-code": "98133", "userid": 0, "age": "25-34" } ], "meta": [ { "id": "46", "type": "node", "labels": [ "user" ] } ] } ], "stats": { "contains_updates": false, "edges_created": 0, "edges_deleted": 0, "labels_set": 0, "properties_set": 0, "vertices_created": 0, "vertices_deleted": 0 } } ], "errors": [] }
Status code: 400
Http Status Code: 200 { "results": [], "errors": [ { "code": "GES.8904", "message": "Label index in vertices is not found." } ] }
Status Codes
Return Value |
Description |
---|---|
400 Bad Request |
Request error. |
401 Unauthorized |
Authorization failed. |
403 Forbidden |
No operation permissions. |
404 Not Found |
No resources found. |
500 Internal Server Error |
Internal server error. |
503 Service Unavailable |
Service unavailable. |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot