Skip to content

Commit c7b30a0

Browse files
authored
vector: adding new fields to vector index (#394)
* tests: adding "error_message" and "training_state" fields for the vector index * test fix
1 parent b7bef5c commit c7b30a0

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

arango/formatter.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ def format_index(body: Json, formatter: bool = True) -> Json:
119119
# Introduced via Vector Index in 3.12.6
120120
if "params" in body:
121121
result["params"] = body["params"]
122+
if "errorMessage" in body:
123+
result["error_message"] = body["errorMessage"]
124+
if "trainingState" in body:
125+
result["training_state"] = body["trainingState"]
122126

123127
return verify_format(body, result)
124128

tests/static/cluster-3.12.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jwt-secret = /tests/static/keyfile
99

1010
[args]
1111
all.database.password = passwd
12+
all.vector-index = true
1213
all.database.extended-names = true
1314
all.log.api-enabled = true
1415
all.javascript.allow-admin-execute = true

tests/static/single-3.12.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ jwt-secret = /tests/static/keyfile
88

99
[args]
1010
all.database.password = passwd
11+
all.vector-index = true
1112
all.database.extended-names = true
1213
all.javascript.allow-admin-execute = true
1314
all.server.options-api = admin

tests/test_index.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
IndexListError,
99
IndexLoadError,
1010
)
11-
from tests.helpers import assert_raises, extract
11+
from tests.helpers import assert_raises, extract, generate_doc_key
1212

1313

1414
def test_list_indexes(icol, bad_col):
@@ -350,6 +350,27 @@ def test_add_mdi_index(icol, db_version):
350350
icol.delete_index(result["id"])
351351

352352

353+
def test_add_vector_index(col):
354+
docs = []
355+
for i in range(100):
356+
docs.append({"_key": generate_doc_key(), "x": [1] * 128})
357+
col.insert_many(docs)
358+
result = col.add_index(
359+
{
360+
"type": "vector",
361+
"fields": ["x"],
362+
"name": "vector_index",
363+
"params": {
364+
"metric": "cosine",
365+
"dimension": 128,
366+
"nLists": 2,
367+
},
368+
}
369+
)
370+
assert result["name"] == "vector_index"
371+
col.delete_index(result["id"])
372+
373+
353374
def test_delete_index(icol, bad_col):
354375
old_indexes = set(extract("id", icol.indexes()))
355376
hash_index = {"type": "hash", "fields": ["attr1", "attr2"], "unique": True}

0 commit comments

Comments
 (0)