Adding Edges in Batches
Function
This API is used to add edges in batches.
URI
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
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
edges |
Yes |
Object |
Edge array to be added |
parallelEdge |
No |
parallelEdge Object |
Repetitive edge processing |
createNotExists |
No |
Boolean |
Whether to add source or target vertices that do not exist in the edges parameter before adding edges. The default value is false, which does not affect the original functions and semantics. If this parameter is set to true, source or target vertices that do not exist in the edges parameter are added prior to the edges. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
source |
Yes |
String |
Source vertex of an edge |
target |
Yes |
String |
Target vertex of an edge |
label |
Yes |
String |
Edge label |
properties |
No |
Object |
Value of each property |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
action |
No |
String |
Processing mode of repetitive edges. The value can be allow, ignore, or override. The default value is allow.
|
ignoreLabel |
No |
Boolean |
Whether to ignore labels on repetitive edges. The value is true or false, and the default value is true.
|
targetProperties |
No |
targetProperties Array |
Properties used to determine duplicate edges. If this parameter is specified, ignoreLabel is set to false to define repetitive edges that contain properties in the list specified by this parameter. (This parameter is mandatory only when action is set to override.)
NOTE:
|
Parameter |
Mandatory |
Type |
Description |
label |
Yes |
String |
Labels whose repetitive edges need to be determined by property |
properties |
Yes |
Array |
List of properties whose repetitive edges need to be determined by property. Currently, only one property is supported. If multiple properties are entered, the first property is used. |
Response Parameters
Parameter |
Type |
Description |
---|---|---|
errorMessage |
String |
System prompt.
|
errorCode |
String |
System prompt code.
|
result |
String |
Request result. If the request is successful, the value is success. If the request fails, the value is failed. |
Example Request
Add edges in batches. The source vertex is 46, the target vertices are 39 and 38, and the edge label is rate.
POST http://{SERVER_URL}/ges/v1.0/{project_id}/graphs/{graph_name}/edges/action?action_id=batch-add { "parallelEdge": { "action": "override", "ignoreLabel": false, "targetProperties": [ { "label": "rate", "properties": [ "Datetime" ] }, { "label": "superclassOf", "properties": [ "popularity" ] } ] }, "createNotExists": true, "edges": [ { "source": "46", "target": "39", "label": "rate", "properties": { "Rating": [ 5 ], "Datetime": [ "2018-01-01 20:30:05" ] } }, { "source": "46", "target": "39", "label": "rate", "properties": { "Rating": [ 4 ], "Datetime": [ "2018-01-01 20:30:05" ] } } ] }
- SERVER_URL: Address for accessing a graph. For details about its value, see Using Service Plane APIs.
- In the example, if vertices 666 and 777 are not in the original graph, create vertices 666 and 777, retain the default value of each label, and add an edge.
Example Response
Status code: 200
Example response for a successful request
Http Status Code: 200 { "result":"success", "data": { "edges": [ { "index": "7", "source": "46", "target": "39" }, { "index": "0", "source": "46", "target": "38" } ] } }
Status code: 400
Example response for a failed request
Http Status Code: 400 { "errorMessage":"edge source vertex [Lily] does not exist", "errorCode":"GES.8000" }
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.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.