Skip to content

PropertyKey API

PropertyKey REST API: Define data types and cardinality constraints for all properties in the graph, serving as fundamental schema elements.

1.2 PropertyKey

Params Description:

  • name: The name of the property type, required.
  • data_type: The data type of the property type, including: bool, byte, int, long, float, double, text, blob, date, uuid. The default data type is text (Represent a string type)
  • cardinality: The cardinality of the property type, including: single, list, set. The default cardinality is single.

Request Body Field Description:

  • id: The ID value of the property type.
  • properties: The properties of the property type. For properties, this field is empty.
  • user_data: Setting the common information of the property type, such as setting the value range of the age property from 0 to 100. Currently, no validation is performed on this field, and it is only a reserved entry for future expansion.

1.2.1 Create a PropertyKey

Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/propertykeys
Request Body
1{
2    "name": "age",
3    "data_type": "INT",
4    "cardinality": "SINGLE"
5}
Response Status
1202
Response Body
 1{
 2    "property_key": {
 3        "id": 1,
 4        "name": "age",
 5        "data_type": "INT",
 6        "cardinality": "SINGLE",
 7        "aggregate_type": "NONE",
 8        "write_type": "OLTP",
 9        "properties": [],
10        "status": "CREATED",
11        "user_data": {
12            "~create_time": "2022-05-13 13:47:23.745"
13        }
14    },
15    "task_id": 0
16}

1.2.2 Add or Remove userdata for an existing PropertyKey

Params
  • action: Indicates whether the current action is to add or remove userdata. Possible values are append (add) and eliminate (remove).
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/propertykeys/age?action=append
Request Body
1{
2    "name": "age",
3    "user_data": {
4        "min": 0,
5        "max": 100
6    }
7}
Response Status
1202
Response Body
 1{
 2    "property_key": {
 3        "id": 1,
 4        "name": "age",
 5        "data_type": "INT",
 6        "cardinality": "SINGLE",
 7        "aggregate_type": "NONE",
 8        "write_type": "OLTP",
 9        "properties": [],
10        "status": "CREATED",
11        "user_data": {
12            "min": 0,
13            "max": 100,
14            "~create_time": "2022-05-13 13:47:23.745"
15        }
16    },
17    "task_id": 0
18}

1.2.3 Get all PropertyKeys

Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/propertykeys
Response Status
1200
Response Body
 1{
 2    "propertykeys": [
 3        {
 4            "id": 3,
 5            "name": "city",
 6            "data_type": "TEXT",
 7            "cardinality": "SINGLE",
 8            "properties": [],
 9            "user_data": {}
10        },
11        {
12            "id": 2,
13            "name": "age",
14            "data_type": "INT",
15            "cardinality": "SINGLE",
16            "properties": [],
17            "user_data": {}
18        },
19        {
20            "id": 5,
21            "name": "lang",
22            "data_type": "TEXT",
23            "cardinality": "SINGLE",
24            "properties": [],
25            "user_data": {}
26        },
27        {
28            "id": 4,
29            "name": "weight",
30            "data_type": "DOUBLE",
31            "cardinality": "SINGLE",
32            "properties": [],
33            "user_data": {}
34        },
35        {
36            "id": 6,
37            "name": "date",
38            "data_type": "TEXT",
39            "cardinality": "SINGLE",
40            "properties": [],
41            "user_data": {}
42        },
43        {
44            "id": 1,
45            "name": "name",
46            "data_type": "TEXT",
47            "cardinality": "SINGLE",
48            "properties": [],
49            "user_data": {}
50        },
51        {
52            "id": 7,
53            "name": "price",
54            "data_type": "INT",
55            "cardinality": "SINGLE",
56            "properties": [],
57            "user_data": {}
58        }
59    ]
60}

1.2.4 Get PropertyKey according to name

Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/propertykeys/age

Where age is the name of the PropertyKey to be retrieved.

Response Status
1200
Response Body
 1{
 2    "id": 1,
 3    "name": "age",
 4    "data_type": "INT",
 5    "cardinality": "SINGLE",
 6    "aggregate_type": "NONE",
 7    "write_type": "OLTP",
 8    "properties": [],
 9    "status": "CREATED",
10    "user_data": {
11        "min": 0,
12        "max": 100,
13        "~create_time": "2022-05-13 13:47:23.745"
14    }
15}

1.2.5 Delete PropertyKey according to name

Method & Url
1DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/propertykeys/age

Where age is the name of the PropertyKey to be deleted.

Response Status
1202
Response Body
1{
2    "task_id" : 0
3}