Skip to content

Commit ad26445

Browse files
committed
docs: update VertexLabel API examples to match HugeGraph v1.5.0
1 parent 0e03726 commit ad26445

1 file changed

Lines changed: 84 additions & 137 deletions

File tree

content/en/docs/clients/restful-api/vertexlabel.md

Lines changed: 84 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ weight: 3
88

99
Assuming that the PropertyKeys listed in 1.1.3 have already been created.
1010

11+
**Note:**
12+
The following examples are verified against HugeGraph Server v1.5.0.
13+
PropertyKeys must be created before creating a VertexLabel.
14+
When running HugeGraph via Docker with the PASSWORD parameter, authentication is enabled and requests must use Basic Auth.
15+
1116
Params Description:
1217

1318
- id: The ID value of the vertex type.
@@ -16,7 +21,7 @@ Params Description:
1621
- properties: The property types associated with the vertex type.
1722
- primary_keys: The primary key properties. This field must have a value when the ID strategy is PRIMARY_KEY, and must be empty for other ID strategies.
1823
- enable_label_index: Whether to enable label indexing. It is disabled by default.
19-
- index_names: The indexes created for the vertex type. See details in section 3.4.
24+
- index_labels: The indexes created for the vertex type. See details in section 3.4.
2025
- nullable_keys: Nullable properties.
2126
- user_data: Setting the common information of the vertex type, similar to the property type.
2227

@@ -32,86 +37,67 @@ POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlab
3237

3338
```json
3439
{
35-
"name": "person",
36-
"id_strategy": "DEFAULT",
37-
"properties": [
38-
"name",
39-
"age"
40-
],
41-
"primary_keys": [
42-
"name"
43-
],
44-
"nullable_keys": [],
45-
"enable_label_index": true
40+
"name": "person",
41+
"id_strategy": "PRIMARY_KEY",
42+
"properties": ["name", "age"],
43+
"primary_keys": ["name"],
44+
"nullable_keys": [],
45+
"enable_label_index": true
4646
}
4747
```
4848

4949
##### Response Status
5050

5151
```json
52-
201
52+
201 Created
5353
```
5454

5555
##### Response Body
5656

5757
```json
5858
{
59-
"id": 1,
60-
"primary_keys": [
61-
"name"
62-
],
63-
"id_strategy": "PRIMARY_KEY",
64-
"name": "person2",
65-
"index_names": [
66-
],
67-
"properties": [
68-
"name",
69-
"age"
70-
],
71-
"nullable_keys": [
72-
],
73-
"enable_label_index": true,
74-
"user_data": {}
59+
"id": 1,
60+
"name": "person",
61+
"id_strategy": "PRIMARY_KEY",
62+
"primary_keys": ["name"],
63+
"nullable_keys": [],
64+
"index_labels": [],
65+
"properties": ["name", "age"],
66+
"status": "CREATED",
67+
"ttl": 0,
68+
"enable_label_index": true,
69+
"user_data": {
70+
"~create_time": "2025-12-16 15:08:57.458"
71+
}
7572
}
7673
```
7774

7875
Starting from version v0.11.2, hugegraph-server supports Time-to-Live (TTL) functionality for vertices. The TTL for vertices is set through VertexLabel. For example, if you want the vertices of type "person" to have a lifespan of one day, you need to set the TTL field to 86400000 (in milliseconds) when creating the "person" VertexLabel.
7976

8077
```json
8178
{
82-
"name": "person",
83-
"id_strategy": "DEFAULT",
84-
"properties": [
85-
"name",
86-
"age"
87-
],
88-
"primary_keys": [
89-
"name"
90-
],
91-
"nullable_keys": [],
92-
"ttl": 86400000,
93-
"enable_label_index": true
79+
"name": "person",
80+
"id_strategy": "PRIMARY_KEY",
81+
"properties": ["name", "age"],
82+
"primary_keys": ["name"],
83+
"nullable_keys": [],
84+
"ttl": 86400000,
85+
"enable_label_index": true
9486
}
9587
```
9688

9789
Additionally, if the vertex has a property called "createdTime" and you want to use it as the starting point for calculating the vertex's lifespan, you can set the ttl_start_time field in the VertexLabel. For example, if the "person" VertexLabel has a property called "createdTime" of type Date, and you want the vertices of type "person" to live for one day starting from the creation time, the Request Body for creating the "person" VertexLabel would be as follows:
9890

9991
```json
10092
{
101-
"name": "person",
102-
"id_strategy": "DEFAULT",
103-
"properties": [
104-
"name",
105-
"age",
106-
"createdTime"
107-
],
108-
"primary_keys": [
109-
"name"
110-
],
111-
"nullable_keys": [],
112-
"ttl": 86400000,
113-
"ttl_start_time": "createdTime",
114-
"enable_label_index": true
93+
"name": "person",
94+
"id_strategy": "PRIMARY_KEY",
95+
"properties": ["name", "age", "createdTime"],
96+
"primary_keys": ["name"],
97+
"nullable_keys": [],
98+
"ttl": 86400000,
99+
"ttl_start_time": "createdTime",
100+
"enable_label_index": true
115101
}
116102
```
117103

@@ -131,14 +117,12 @@ PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabe
131117

132118
```json
133119
{
134-
"name": "person",
135-
"properties": [
136-
"city"
137-
],
138-
"nullable_keys": ["city"],
139-
"user_data": {
140-
"super": "animal"
141-
}
120+
"name": "person",
121+
"properties": ["city"],
122+
"nullable_keys": ["city"],
123+
"user_data": {
124+
"super": "animal"
125+
}
142126
}
143127
```
144128

@@ -152,26 +136,17 @@ PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabe
152136

153137
```json
154138
{
155-
"id": 1,
156-
"primary_keys": [
157-
"name"
158-
],
159-
"id_strategy": "PRIMARY_KEY",
160-
"name": "person",
161-
"index_names": [
162-
],
163-
"properties": [
164-
"city",
165-
"name",
166-
"age"
167-
],
168-
"nullable_keys": [
169-
"city"
170-
],
171-
"enable_label_index": true,
172-
"user_data": {
173-
"super": "animal"
174-
}
139+
"id": 1,
140+
"primary_keys": ["name"],
141+
"id_strategy": "PRIMARY_KEY",
142+
"name": "person",
143+
"index_labels": [],
144+
"properties": ["city", "name", "age"],
145+
"nullable_keys": ["city"],
146+
"enable_label_index": true,
147+
"user_data": {
148+
"super": "animal"
149+
}
175150
}
176151
```
177152

@@ -193,50 +168,23 @@ GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabe
193168

194169
```json
195170
{
196-
"vertexlabels": [
197-
{
198-
"id": 1,
199-
"primary_keys": [
200-
"name"
201-
],
202-
"id_strategy": "PRIMARY_KEY",
203-
"name": "person",
204-
"index_names": [
205-
],
206-
"properties": [
207-
"city",
208-
"name",
209-
"age"
210-
],
211-
"nullable_keys": [
212-
"city"
213-
],
214-
"enable_label_index": true,
215-
"user_data": {
216-
"super": "animal"
217-
}
218-
},
219-
{
220-
"id": 2,
221-
"primary_keys": [
222-
"name"
223-
],
224-
"id_strategy": "PRIMARY_KEY",
225-
"name": "software",
226-
"index_names": [
227-
],
228-
"properties": [
229-
"price",
230-
"name",
231-
"lang"
232-
],
233-
"nullable_keys": [
234-
"price"
235-
],
236-
"enable_label_index": false,
237-
"user_data": {}
238-
}
239-
]
171+
"vertexlabels": [
172+
{
173+
"id": 1,
174+
"name": "person",
175+
"id_strategy": "PRIMARY_KEY",
176+
"primary_keys": ["name"],
177+
"nullable_keys": [],
178+
"index_labels": [],
179+
"properties": ["name", "age"],
180+
"status": "CREATED",
181+
"ttl": 0,
182+
"enable_label_index": true,
183+
"user_data": {
184+
"~create_time": "2025-12-16 15:08:57.458"
185+
}
186+
}
187+
]
240188
}
241189
```
242190

@@ -257,26 +205,25 @@ GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabe
257205
##### Response Body
258206

259207
```json
208+
260209
{
261210
"id": 1,
211+
"name": "person",
212+
"id_strategy": "PRIMARY_KEY",
262213
"primary_keys": [
263214
"name"
264215
],
265-
"id_strategy": "PRIMARY_KEY",
266-
"name": "person",
267-
"index_names": [
268-
],
216+
"nullable_keys": [],
217+
"index_labels": [],
269218
"properties": [
270-
"city",
271219
"name",
272220
"age"
273221
],
274-
"nullable_keys": [
275-
"city"
276-
],
222+
"status": "CREATED",
223+
"ttl": 0,
277224
"enable_label_index": true,
278225
"user_data": {
279-
"super": "animal"
226+
"~create_time": "2025-12-16 15:08:57.458"
280227
}
281228
}
282229
```
@@ -301,7 +248,7 @@ DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexl
301248

302249
```json
303250
{
304-
"task_id": 1
251+
"task_id": 1
305252
}
306253
```
307254

0 commit comments

Comments
 (0)