Updated on 2023-08-04 GMT+08:00

Querying a Subgraph (2.1.13)

Function

This API is used to query the subgraphs formed by the entered vertices and edges between the vertices.

URI

POST /ges/v1.0/{project_id}/graphs/{graph_name}/subgraphs/action?action_id=query
Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

graph_name

Yes

String

Graph name

Request Parameters

Table 2 Request body parameter

Parameter

Mandatory

Type

Description

vertices

Yes

String

Vertex ID array of the subgraph

NOTE:

The maximum number of vertices that can be entered is 100,000. If the number of vertices exceeds this limit, an error is reported.

Response Parameters

Table 3 Response body parameters

Parameter

Type

Description

errorMessage

String

System prompt.

  • If execution succeeds, this parameter may be left blank.
  • If execution fails, this parameter is used to display the error message.

errorCode

String

System prompt code.

  • If execution succeeds, this parameter may be left blank.
  • If execution fails, this parameter is used to display the error code.

data

Object

The data field is contained when the query is successful, and the data field contains the subgraph query result.

NOTE:

The maximum number of subgraph edges that can be returned is 100,000. If the number of edges exceeds this limit, an error is reported.

Example Request

Query the subgraphs formed by the entered vertices and edges between the vertices. The subgraph vertex IDs are Ray, Ella, and Lethal Weapon.

{
    "vertices":[
               "Ray",
               "Ella",
               "Lethal Weapon"        
               ]
}

Example Response

Status code: 200

Example response (successful request)

Http Status Code: 200
{
    "data":{
        "vertices":[
            {
                "id":"Ray",
                "label":"user",
                "properties":{
                    "Name": ["Ray"],
                    "Gender":["M"],
                    "Age":["18-24"],
                    "Occupation":["college/grad student"],
                    "Zip-code":["90241"]
                }
            },
            {
                "id":"Ella",
                "label":"user",
                "properties":{
                    "Occupation":["other or not specified"],
                    "Name": ["Era"],
                    "Zip-code":["94402"],
                    "Gender":["F"],
                    "Age":["25-34"]
                }
            }
        ],
        "edges":[
            {
                "source":"Ray",
                "target":"Lethal Weapon",
                "index":"1",
                "label":"rate",
                "properties":{
                    "Score":[2],
                    "Datetime":["2000-11-22 19:16:16"]
                }
            },
            {
                "index":"0",
                "source":"Ella",
                "label":"rate",
                "properties":{
                    "Score":[5],
                    "Datetime":["2000-11-23 02:30:29"]
                },
                "target":"Lethal Weapon"
            },
            {
                "index":"5",
                "source":"Ella",
                "label":"friends",
                "properties":{},
                "target":"Ray"
            }
        ]
    }
}

Status code: 400

Example response for a failed request
Http Status Code: 400
{
  "errorMessage": " Bad Request, parameter vertices cannot be null",
  "errorCode": "GES.8214"
}

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.

Error Codes

See Error Codes.