更新时间:2022-02-22 GMT+08:00

批量添加边

功能介绍

批量添加边。

URI

  • URI格式
    POST /ges/v1.0/{project_id}/graphs/{graph_name}/edges/action?action_id=batch-add
  • 参数说明
    表1 URI参数说明

    参数

    是否必选

    类型

    说明

    project_id

    String

    项目编号,用于资源隔离。请参考获取项目ID

    graph_name

    String

    图名称。

请求

  • 请求样例
    POST http://{SERVER_URL}/ges/v1.0/{project_id}/graphs/{graph_name}/edges/action?action_id=batch-add
    {
        "edges": [
            {
                "source": "46",
                "target": "39",
                "label": "rate",
                "properties": {
                    "Rating": [
                        5
                    ],
                    "Datetime": [
                        "2018-01-0120:30:05"
                    ]
                }
            },
            {
                "source": "46",
                "target": "38",
                "label": "rate",
                "properties": {
                    "Rating": [
                        4
                    ],
                    "Datetime": [
                        "2018-01-0120:30:05"
                    ]
                }
            }
        ],
        "parallelEdge": {
            "action": "override",
            "ignoreLabel": true
        },
        "createNotExists": true
    }
    • SERVER_URL:图的访问地址,取值请参考业务面API使用限制
    • 样例中,若假设点666和777不在原图中,则创建666和777两个点,且label为默认值,之后再添加边。
  • Body参数说明

    参数

    是否必选

    类型

    说明

    edges

    Json

    待添加边数组

    parallelEdge

    Object

    重复边处理

    action

    String

    处理方式,取值为allow,ignore和override,默认为allow。

    • allow表示允许重复边。
    • ignore表示忽略之后的重复边。
    • override表示覆盖之前的重复边。

    ignoreLabel

    Boolean

    重复边的定义,是否忽略Label。取值为true或者false,默认取true。

    • true 表示重复边定义不包含Label,即用<源点,终点>标记一条边,不包含Label。
    • false 表示重复边定义包含Label,即用<源点,终点,Label>标记一条边。

    createNotExists

    Boolean

    对于edges参数中不存在的source或target节点,是否会先添加这些点,再执行添加边操作。默认值为“false”(不影响原功能和语义)。

    当值为“true”时,对于edges参数中不存在的source或target节点,会先添加这些点,再执行添加边操作。

    表2 edges参数说明

    参数

    是否必选

    类型

    说明

    source

    String

    边的source节点。

    target

    String

    边的target节点。

    label

    String

    边的label。

    properties

    Json

    各个属性的值。

响应

  • 要素说明

    参数

    是否必选

    类型

    说明

    errorMessage

    String

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

    errorCode

    String

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

    result

    String

    成功时result值为success。

  • 请求成功样例
    Http Status Code: 200
    {
     "result":"success",
     "data": {
         "edges": [
             {
                 "index": "7",
                 "source": "46",
                 "target": "39"
             },
             {
                 "index": "0",
                 "source": "46",
                 "target": "38"
             }
         ]
     }
    }
  • 请求失败样例
    Http Status Code: 400
    {
     "errorMessage":"edge source vertex [Lily] does not exist",
     "errorCode":"GES.8000"
    }

返回值

  • 正常

    200

  • 异常
    表3 异常返回值说明

    返回值

    说明

    400 Bad Request

    请求错误。

    401 Unauthorized

    鉴权失败。

    403 Forbidden

    没有操作权限。

    404 Not Found

    找不到资源。

    500 Internal Server Error

    服务内部错误。

    503 Service Unavailable

    服务不可用。