Updated on 2022-02-22 GMT+08:00

Querying a Subgraph

Function

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

URI

  • URI format
    POST /ges/v1.0/{project_id}/graphs/{graph_name}/subgraphs/action?action_id=query
  • Parameter description
    Table 1 URI parameter description

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    String

    Project ID, which is used for resource isolation. For details, see Obtaining a Project ID.

    graph_name

    Yes

    String

    Graph name

Request

  • Request example
    {
        "vertices":[
                   "Ray",
                   "Ella",
                   "Lethal Weapon"        
                   ]
    }
  • Parameter description
    Table 2

    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

Table 3 Parameter description

Parameter

Mandatory

Type

Description

errorMessage

No

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

No

String

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

data

No

Json

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.

  • Response example (successful request)
    Http Status Code: 200
    {
        "data":{
            "vertices":[
                {
                    "id":"Ray",
                    "label":"user",
                    "properties":{
                        "ChineseName":["Lei"],
                        "Gender":["M"],
                        "Age":["18-24"],
                        "Occupation":["college/grad student"],
                        "Zip-code":["90241"]
                    }
                },
                {
                    "id":"Ella",
                    "label":"user",
                    "properties":{
                        "Occupation":["other or not specified"],
                        "ChineseName":["Ella"],
                        "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"
                }
            ]
        }
    }
  • Response example (failed request)
    Http Status Code: 400
    {
      "errorMessage": " Bad Request, parameter vertices cannot be null",
      "errorCode": "GES.8214"
    }

Return Value

  • Normal

    200

  • Abnormal
    Table 4 Return code for failed requests

    Return Value

    Description

    400 Bad Request

    Request error.

    401 Unauthorized

    Authentication failed.

    403 Forbidden

    No operation permission.

    404 Not Found

    The requested resource was not found.

    500 Internal Server Error

    Internal service error.

    503 Service Unavailable

    Service unavailable.