Schema definition with vector capabilities
This topic describes how to define vector properties and vector indexes in vertex schemas of the Lindorm graph engine. The related APIs are fully reused from the Schema definition topic.
Prerequisites
-
Lindorm Graph Engine is activated and the access whitelist is configured.
-
Lindorm Vector Engine is activated.
-
The connection endpoint, database name, username, and password of the graph engine are obtained.
Notes
When using vector properties, note the following limits:
-
Vector properties are supported only on vertices. Edges do not support vector properties.
-
Do not name a vertex property
_score. This name is reserved for vector search results. -
Only FLOAT32 vectors are supported. The corresponding property type is
VECTOR_FLOAT. -
VECTOR_FLOATmust be used together withvectorMeta. -
A single vertex type can have multiple vector properties, each with its own dimension and index configuration.
-
The distance method is determined at the Schema level and cannot be changed per query.
Vector property definition
Basic structure
Vector indexes are created through the Schema API. Currently, vector properties are supported only on vertices. Set dataType to VECTOR_FLOAT in a vertex property and configure vectorMeta. The system creates a corresponding vector index table for the vertex type.
Example of a vector property definition:
{
"name": "embedding",
"dataType": "VECTOR_FLOAT",
"vectorMeta": {
"dimension": 128,
"distanceMethod": "L2",
"indexType": "HNSW",
"indexParams": {
"M": "24",
"EF_CONSTRUCT": "200"
}
}
}
Common parameters
|
Parameter |
Required |
Description |
|
|
Yes |
The number of dimensions of the vector. Valid values: |
|
|
No |
The distance metric. Default value: |
|
|
No |
The index type. Default value: |
|
|
No |
The index parameters, specified as key-value string pairs. Different index types support different parameters. |
indexParams has different parameter requirements for different index types.
Index parameters
HNSW index parameters
HNSW is a hierarchical navigable small world graph index. It takes effect immediately upon data write and does not require manual building.
|
Parameter |
Type |
Default |
Valid values |
Description |
|
|
int |
24 |
|
The maximum number of outgoing edges at each layer of the graph. Optional. |
|
|
int |
500 |
|
The length of the dynamic list during index construction. Optional. |
HNSWQ index parameters
HNSWQ is a compressed index that combines HNSW with multi-level quantization. It requires manual triggering of the build process after training data is written.
|
Parameter |
Type |
Default |
Valid values |
Description |
|
|
int |
24 |
|
The maximum number of outgoing edges at each layer of the graph. Optional. |
|
|
int |
500 |
|
The length of the dynamic list during index construction. Optional. |
IVFPQ index parameters
IVFPQ is an index that combines inverted file with product quantization. It requires manual triggering of the build process after training data is written.
|
Parameter |
Type |
Default |
Valid values |
Description |
|
|
int |
|
|
The number of subspaces in product quantization. Optional. Important
When creating an IVFPQ index, the value of this parameter must be the same as the value of the |
|
|
int |
10000 |
|
The number of clustering centers. Optional. |
IVFBQ index parameters
IVFBQ is an index that combines inverted file with binary quantization (RaBitQ). It requires manual triggering of the build process after training data is written.
|
Parameter |
Type |
Default |
Valid values |
Description |
|
|
int |
0 |
|
Specifies the number of additional bytes used to represent quantized vectors. A larger value indicates higher precision but greater storage overhead. Optional. |
|
|
int |
10000 |
|
The number of clustering centers. Optional. |
Initialize a graph Schema with vector capabilities
This section provides only some examples. For detailed API descriptions and limits, see the Schema definition topic.
The API endpoint is POST /schema/mgmt/apply?db=${DB_NAME}. The following example defines a person vertex type with regular properties named name and age, and a 128-dimensional HNSW vector property named embedding:
curl -X POST \
"http://${SERVER_HOST}:${GREMLIN_PORT}/schema/mgmt/apply?db=${DB_NAME}" \
-u "${SUB_USER}:${SUB_PASSWORD}" \
-H 'Content-Type: application/json' \
-d '{
"vertexLabels": [{
"label": "person",
"properties": [
{"name": "name", "dataType": "STRING"},
{"name": "age", "dataType": "INT"},
{
"name": "embedding",
"dataType": "VECTOR_FLOAT",
"vectorMeta": {
"dimension": 128,
"distanceMethod": "L2",
"indexType": "HNSW",
"indexParams": {
"M": "24",
"EF_CONSTRUCT": "200"
}
}
}
]
}]
}'
Sample response:
{
"status": "200 OK",
"payload": {
"vertexLabelsCreated": [
"person"
],
"edgeLabelsCreated": [],
"connectionsRegistered": []
}
}
Extend vector capabilities for an existing Schema
This section provides only some examples. For detailed API descriptions and limits, see the Schema definition topic.
Add vector properties to an existing vertex type
The API endpoint is POST /schema/mgmt/addProperty?db=${DB_NAME}. The following example adds a 128-dimensional HNSW vector property named embedding to the person vertex type.
curl -X POST \
"http://${SERVER_HOST}:${GREMLIN_PORT}/schema/mgmt/addProperty?db=${DB_NAME}" \
-u "${SUB_USER}:${SUB_PASSWORD}" \
-H 'Content-Type: application/json' \
-d '{
"label": "person",
"labelType": "vertex",
"properties": [{
"name": "embedding",
"dataType": "VECTOR_FLOAT",
"vectorMeta": {
"dimension": 128,
"distanceMethod": "L2",
"indexType": "HNSW",
"indexParams": {
"M": "16",
"EF_CONSTRUCT": "200"
}
}
}]
}'
Sample response:
{
"status": "200 OK",
"payload": {
"label": "person",
"labelType": "vertex",
"propertiesAdded": [
"embedding"
]
}
}
Add a new vertex type with vector properties
The API endpoint is POST /schema/mgmt/addVertexLabel?db=${DB_NAME}. The following example adds an article vertex type to an existing subgraph, with a regular property named title and a 512-dimensional IVFBQ vector property named content_vector:
curl -X POST \
"http://${SERVER_HOST}:${GREMLIN_PORT}/schema/mgmt/addVertexLabel?db=${DB_NAME}" \
-u "${SUB_USER}:${SUB_PASSWORD}" \
-H 'Content-Type: application/json' \
-d '{
"label": "article",
"properties": [
{"name": "title", "dataType": "STRING"},
{
"name": "content_vector",
"dataType": "VECTOR_FLOAT",
"vectorMeta": {
"dimension": 512,
"distanceMethod": "COSINE",
"indexType": "IVFBQ",
"indexParams": {
"NLIST": "5000",
"EXBITS": "2"
}
}
}
]
}'
Sample response:
{
"status": "200 OK",
"payload": {
"vertexLabelCreated": "article",
"propertiesCount": 2
}
}