批量添加label(2.2.21)
功能介绍
批量添加label。
URI
POST /ges/v1.0/{project_id}/graphs/{graph_name}/schema/labels/action?action_id=batch-add 参数 | 是否必选 | 类型 | 说明 |
|---|---|---|---|
project_id | 是 | String | 参数解释: 项目编号。获取方法,请参见获取项目ID。 约束限制: 不涉及。 取值范围: 只能由英文字母和数字组成,且长度为[1-64]个字符。 默认取值: 不涉及。 |
graph_name | 是 | String | 图名称。 |
请求参数
参数 | 是否必选 | 类型 | 说明 |
|---|---|---|---|
labels | 是 | Object | 元数据label名称。 |
参数 | 是否必选 | 类型 | 说明 |
|---|---|---|---|
name | 是 | String | label的名称。长度不能超过256,只允许字符,数字, 空格,%,@,#,$,:,?,*,.,+,-和_符号。 |
type | 否 | String | Label类别,表示此label用于点或边,取值为“vertex”或“edge”或“all”。默认值为“all”,表示label作用于点和边。 |
properties | 是 | Object | 待添加属性数组。数组元素为property,具体参数介绍请见property参数说明。 |
参数 | 是否必选 | 类型 | 说明 |
|---|---|---|---|
name | 是 | String | 属性名称。
|
cardinality | 是 | String | 属性的复合类型,包括:
|
dataType | 是 | String | 属性的数据类型。具体请参考元数据属性约束条件中的元数据类型。 |
typeNameCount | 否(若dataType为enum,则必选) | String | enum类型参数的总数。由该选项控制typeName的个数。 |
typeName* | 否(若dataType为enum,则必选) | String | enum类型参数名称。例如typeNameCount为2,则参数包含typeName1:science,typeName2:literature。 |
响应参数
参数 | 类型 | 说明 |
|---|---|---|
errorMessage | String | 参数解释: 系统提示信息。
取值范围: 不涉及。 |
errorCode | String | 参数解释: 系统提示信息。
取值范围: 不涉及。 |
result | String | 响应结果。成功时result值为success。 |
data | Object | 当批量添加部分失败时,data字段包含失败的label_name以及失败原因。 |
请求示例
批量添加元数据label,元数据label的名称分别为book和movie,以及两个label的待添加属性数组。
POST http://{SERVER_URL}/ges/v1.0/{project_id}/graphs/{graph_name}/schema/labels/action?action_id=batch-add
{
"labels": [
{
"name": "book",
"type": "vertex",
"properties": [
{
"property": {
"name": "title",
"cardinality": "single",
"dataType": "string"
}
}
]
},
{
"name": "movie",
"type": "vertex",
"properties": [
{
"property": {
"name": "movieid",
"cardinality": "single",
"dataType": "int"
}
}
]
}
]
}

SERVER_URL:图的访问地址,取值请参考业务面API使用限制。
响应示例
状态码: 200
成功响应示例
Http Status Code: 200
{
"result": "success"
} Http Status Code: 200
{
"result": "partial success",
"data": {
"failed": [
{
"cause": "label name is invalid which can only contain letters, digits, space,%,@,#,$,:,?,*,.,+,- and _",
"labelName": "book<"
}
]
}
} 状态码: 400
失败响应示例
Http Status Code: 400
{
"errorMessage": "Label : movie already exists",
"errorCode": "GES.8812"
} 状态码
返回值 | 说明 |
|---|---|
202 Accepted | 请求已接收,暂未处理。 |
400 Bad Request | 请求错误。 |
401 Unauthorized | 鉴权失败。 |
403 Forbidden | 没有操作权限。 |
404 Not Found | 找不到资源。 |
500 Internal Server Error | 服务内部错误。 |
503 Service Unavailable | 服务不可用。 |
错误码
请参见错误码。

