文档 1.7 版本已不再积极维护,你当前浏览的是一份归档快照。
最新文档请参阅 最新版本。
IndexLabel API
1.5 IndexLabel
假设已经创建好了 1.1.3 中的 PropertyKeys、1.2.3 中的 VertexLabels 以及 1.3.3 中的 EdgeLabels
1.5.1 创建一个 IndexLabel
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/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
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.5.2 获取所有的 IndexLabel
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/indexlabels
Response Status
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.5.3 根据 name 获取 IndexLabel
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/indexlabels/personByCity
Response Status
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.5.4 根据 name 删除 IndexLabel
删除 IndexLabel 会导致删除相关的索引数据,会产生一个异步任务
Method & Url
1DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/indexlabels/personByCity
Response Status
Response Body
注:
可以通过GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/1(其中"1"是 task_id)来查询异步任务的执行状态,更多异步任务 RESTful API