更新时间:2025-03-05 GMT+08:00

查询树详情

功能介绍

输入一个点,输出以该点为起点的一棵树, 包括树中的节点和边,以及可达路径信息。参数可以为方向(出、入、出和入)、最大跳数和需要过滤的边属性等。

URI

POST /ges/v1.0/{project_id}/graphs/{graph_name}/action?action_id=query-tree
表1 路径参数

参数

是否必选

类型

说明

project_id

String

项目ID。获取方法请参见获取项目ID

graph_name

String

图名称。

请求示例

Post /ges/v1.0/{project_id}/graphs/test/action?action_id=query-tree
{
    "executionMode": "sync",
    "rootId": "0",
    "maxDepth": 20,
    "maxVertices": 5000,
    "maxEdges": 10000,
    "maxDegree": 1000,
    "direction": "both",
    "labelFilters": [
        "edge",
        "default"
    ],
    "withVertex": true,
    "withEdge": true
}

请求参数

表2 Body参数说明

参数

是否必选

类型

说明

executionMode

String

  • sync:同步
  • async:异步

默认为“async”,异步返回。

rootId

String

根节点ID。

maxDepth

Integer

树深度,也是路径的最大长度,取值范围[1,20]。

direction

String

可选值。

in:查询入边;

out:查询出边;

both:查询出边和入边。

labelFilters

Array of Json

按label过滤路径,默认为“[]”。

maxVertices

Integer

最多可获得的点数,取值范围(0,200000]。

maxEdges

Integer

最多可获得的边数,取值范围(0,200000]。

maxDegree

Long

用于超级节点的访问,当访问到的节点单向所连边数大于maxDegree时,将不再访问该节点的下一跳。

withVertex

Boolean

是否输出点数据,默认为“true”。

withEdge

Boolean

是否输出边数据,默认为“true”。

异步状态下同时输出点和边数据,不支持分页。

响应参数

表3 响应Body参数说明

参数

类型

说明

errorMessage

String

系统提示信息。

  • 执行成功时,字段可能为空。
  • 执行失败时,用于显示错误信息。

errorCode

String

系统提示信息。

  • 执行成功时,字段可能为空。
  • 执行失败时,用于显示错误码。

data

Object

查询结果。具体请参考表4表5

查询失败时,字段为空。

表4 同步data参数说明

参数

类型

说明

vertices

List

点的结果集合。没有查询到对应点时,vertices内容为空。

edges

List

边的结果集合。没有查询到对应边时,edges内容为空。

表5 异步data说明

参数

类型

说明

jobId

String

执行算法任务ID。请求失败时,该字段为空。

jobType

Integer

任务类型。请求失败时,该字段为空。

响应示例

  • 同步

    状态码: 200

    成功响应示例

    Http Status Code: 200
    {
    "data": {
       "edges" : [
          {
             "index" : "0",
             "label" : "edge",
             "properties" : {
                "_type" : [ "ACTED_IN" ],
                "role" : [ "Neo" ]
             },
             "source" : "546",
             "target" : "0"
          },
         ...
       ],
       "vertices" : [
          {
             "id" : "546",
             "label" : "node",
             "properties" : {
                "_labels" : [ "Actor" ],
                "d" : [ "" ],
                "name" : [ "Keanu Reeves" ],
                "personId" : [ "keanu" ],
                "title" : [ "" ],
                "year" : [ "" ]
             }
          },
       …
       ]
    }
    }
    

    状态码: 400

    失败响应示例
    Http Status Code: 400
    {
        "errorMessage": "graph [test] is not found",
        "errorCode": "GES.8808"
    }
  • 异步

    状态码: 200

    成功响应样例
    {
        "jobId": "aca63a57-55f9-4c6e-932f-bcd6b87f7ab4",
        "jobType": 1
    }

    状态码: 400

    失败响应示例(异步)

    Http Status Code: 400
    {
        "errorMessage": "executionMode is not correct, it should be sync or async",
        "errorCode": "GES.8808"
    }

状态码

返回值

说明

400 Bad Request

请求错误。

401 Unauthorized

鉴权失败。

403 Forbidden

没有操作权限。

404 Not Found

找不到资源。

500 Internal Server Error

服务内部错误。

503 Service Unavailable

服务不可用。

错误码

请参见错误码