IndexLabel API IndexLabel REST API: Create indexes on vertex and edge properties to accelerate property-based queries and filtering operations.
1.5 IndexLabel Assuming PropertyKeys from version 1.1.3, VertexLabels from version 1.2.3, and EdgeLabels from version 1.3.3 have already been created.
1.5.1 Create an IndexLabel Method & Url
1 POST 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 Get all IndexLabels Method & Url
1 GET 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 Get IndexLabel by name Method & Url
1 GET 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 Delete IndexLabel by name Deleting an IndexLabel will result in the deletion of related index data. This operation will generate an asynchronous task.
Method & Url
1 DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/indexlabels/personByCity Response Status Response Body Note:
You can query the execution status of an asynchronous task by using GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/1 (where “1” is the task_id). For more information, refer to the Asynchronous Task RESTful API .
1.5.5 Add or remove userdata for an existing IndexLabel Only user_data can be changed this way, base_type, base_value and index_type must be left out of the request body.
Params action: Indicates whether the current action is to add or remove userdata. Possible values are append (add) and eliminate (remove). Method & Url
1 PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/indexlabels/personByCity?action=append Request Body
1 {
2 "name" : "personByCity" ,
3 "user_data" : {
4 "comment" : "index on city"
5 }
6 } 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 "user_data" : {
11 "comment" : "index on city" ,
12 "~create_time" : "2022-05-13 13:47:23.745"
13 }
14 }