1.4 IndexLabel

假设已经创建好了1.1.3中的 PropertyKeys 、1.2.3中的 VertexLabels 以及 1.3.3中的 EdgeLabels

1.4.1 创建一个IndexLabel

Method & Url
  1. POST http://localhost:8080/graphs/hugegraph/schema/indexlabels
Request Body
  1. {
  2. "name": "personByCity",
  3. "base_type": "VERTEX_LABEL",
  4. "base_value": "person",
  5. "index_type": "SECONDARY",
  6. "fields": [
  7. "city"
  8. ]
  9. }
Response Status
  1. 202
Response Body
  1. {
  2. "index_label": {
  3. "id": 1,
  4. "base_type": "VERTEX_LABEL",
  5. "base_value": "person",
  6. "name": "personByCity",
  7. "fields": [
  8. "city"
  9. ],
  10. "index_type": "SECONDARY"
  11. },
  12. "task_id": 2
  13. }

1.4.2 获取所有的IndexLabel

Method & Url
  1. GET http://localhost:8080/graphs/hugegraph/schema/indexlabels
Response Status
  1. 200
Response Body
  1. {
  2. "indexlabels": [
  3. {
  4. "id": 3,
  5. "base_type": "VERTEX_LABEL",
  6. "base_value": "software",
  7. "name": "softwareByPrice",
  8. "fields": [
  9. "price"
  10. ],
  11. "index_type": "RANGE"
  12. },
  13. {
  14. "id": 4,
  15. "base_type": "EDGE_LABEL",
  16. "base_value": "created",
  17. "name": "createdByDate",
  18. "fields": [
  19. "date"
  20. ],
  21. "index_type": "SECONDARY"
  22. },
  23. {
  24. "id": 1,
  25. "base_type": "VERTEX_LABEL",
  26. "base_value": "person",
  27. "name": "personByCity",
  28. "fields": [
  29. "city"
  30. ],
  31. "index_type": "SECONDARY"
  32. },
  33. {
  34. "id": 3,
  35. "base_type": "VERTEX_LABEL",
  36. "base_value": "person",
  37. "name": "personByAgeAndCity",
  38. "fields": [
  39. "age",
  40. "city"
  41. ],
  42. "index_type": "SECONDARY"
  43. }
  44. ]
  45. }

1.4.3 根据name获取IndexLabel

Method & Url
  1. GET http://localhost:8080/graphs/hugegraph/schema/indexlabels/personByCity
Response Status
  1. 200
Response Body
  1. {
  2. "id": 1,
  3. "base_type": "VERTEX_LABEL",
  4. "base_value": "person",
  5. "name": "personByCity",
  6. "fields": [
  7. "city"
  8. ],
  9. "index_type": "SECONDARY"
  10. }

1.4.4 根据name删除IndexLabel

删除 IndexLabel 会导致删除相关的索引数据,会产生一个异步任务

Method & Url
  1. DELETE http://localhost:8080/graphs/hugegraph/schema/indexlabels/personByCity
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