1.3 EdgeLabel

假设已经创建好了1.1.3中的 PropertyKeys 和 1.2.3中的 VertexLabels

1.3.1 创建一个EdgeLabel

Method & Url
  1. POST http://localhost:8080/graphs/hugegraph/schema/edgelabels
Request Body
  1. {
  2. "name": "created",
  3. "source_label": "person",
  4. "target_label": "software",
  5. "frequency": "SINGLE",
  6. "properties": [
  7. "date"
  8. ],
  9. "sort_keys": [],
  10. "nullable_keys": [],
  11. "enable_label_index": true
  12. }
Response Status
  1. 201
Response Body
  1. {
  2. "id": 1,
  3. "sort_keys": [
  4. ],
  5. "source_label": "person",
  6. "name": "created",
  7. "index_names": [
  8. ],
  9. "properties": [
  10. "date"
  11. ],
  12. "target_label": "software",
  13. "frequency": "SINGLE",
  14. "nullable_keys": [
  15. ],
  16. "enable_label_index": true,
  17. "user_data": {}
  18. }

1.3.2 为已存在的EdgeLabel添加properties或userdata,或者移除userdata(目前不支持移除properties)

Params
  • action: 表示当前行为是添加还是移除,取值为append(添加)和eliminate(移除)
Method & Url
  1. PUT http://localhost:8080/graphs/hugegraph/schema/edgelabels/created?action=append
Request Body
  1. {
  2. "name": "created",
  3. "properties": [
  4. "weight"
  5. ],
  6. "nullable_keys": [
  7. "weight"
  8. ]
  9. }
Response Status
  1. 200
Response Body
  1. {
  2. "id": 2,
  3. "sort_keys": [
  4. ],
  5. "source_label": "person",
  6. "name": "created",
  7. "index_names": [
  8. ],
  9. "properties": [
  10. "date",
  11. "weight"
  12. ],
  13. "target_label": "software",
  14. "frequency": "SINGLE",
  15. "nullable_keys": [
  16. "weight"
  17. ],
  18. "enable_label_index": true,
  19. "user_data": {}
  20. }

1.3.3 获取所有的EdgeLabel

Method & Url
  1. GET http://localhost:8080/graphs/hugegraph/schema/edgelabels
Response Status
  1. 200
Response Body
  1. {
  2. "edgelabels": [
  3. {
  4. "id": 1,
  5. "sort_keys": [
  6. ],
  7. "source_label": "person",
  8. "name": "created",
  9. "index_names": [
  10. ],
  11. "properties": [
  12. "date",
  13. "weight"
  14. ],
  15. "target_label": "software",
  16. "frequency": "SINGLE",
  17. "nullable_keys": [
  18. "weight"
  19. ],
  20. "enable_label_index": true,
  21. "user_data": {}
  22. },
  23. {
  24. "id": 2,
  25. "sort_keys": [
  26. ],
  27. "source_label": "person",
  28. "name": "knows",
  29. "index_names": [
  30. ],
  31. "properties": [
  32. "date",
  33. "weight"
  34. ],
  35. "target_label": "person",
  36. "frequency": "SINGLE",
  37. "nullable_keys": [
  38. ],
  39. "enable_label_index": false,
  40. "user_data": {}
  41. }
  42. ]
  43. }

1.3.4 根据name获取EdgeLabel

Method & Url
  1. GET http://localhost:8080/graphs/hugegraph/schema/edgelabels/created
Response Status
  1. 200
Response Body
  1. {
  2. "id": 1,
  3. "sort_keys": [
  4. ],
  5. "source_label": "person",
  6. "name": "created",
  7. "index_names": [
  8. ],
  9. "properties": [
  10. "date",
  11. "city",
  12. "weight"
  13. ],
  14. "target_label": "software",
  15. "frequency": "SINGLE",
  16. "nullable_keys": [
  17. "city",
  18. "weight"
  19. ],
  20. "enable_label_index": true,
  21. "user_data": {}
  22. }

1.3.5 根据name删除EdgeLabel

删除 EdgeLabel 会导致删除对应的边以及相关的索引数据,会产生一个异步任务

Method & Url
  1. DELETE http://localhost:8080/graphs/hugegraph/schema/edgelabels/created
Response Status
  1. 202
Response Body
  1. {
  2. "task_id": 1
  3. }

注:

可以通过GET http://localhost:8080/graphs/hugegraph/tasks/1(其中”1”是task_id)来查询异步任务的执行状态,更多异步任务RESTful API