diff --git a/arango/formatter.py b/arango/formatter.py index e159c23..568be24 100644 --- a/arango/formatter.py +++ b/arango/formatter.py @@ -119,6 +119,10 @@ def format_index(body: Json, formatter: bool = True) -> Json: # Introduced via Vector Index in 3.12.6 if "params" in body: result["params"] = body["params"] + if "errorMessage" in body: + result["error_message"] = body["errorMessage"] + if "trainingState" in body: + result["training_state"] = body["trainingState"] return verify_format(body, result) diff --git a/tests/static/cluster-3.12.conf b/tests/static/cluster-3.12.conf index 3773711..6e325cc 100644 --- a/tests/static/cluster-3.12.conf +++ b/tests/static/cluster-3.12.conf @@ -9,6 +9,7 @@ jwt-secret = /tests/static/keyfile [args] all.database.password = passwd +all.vector-index = true all.database.extended-names = true all.log.api-enabled = true all.javascript.allow-admin-execute = true diff --git a/tests/static/single-3.12.conf b/tests/static/single-3.12.conf index 3c43883..185ff7e 100644 --- a/tests/static/single-3.12.conf +++ b/tests/static/single-3.12.conf @@ -8,6 +8,7 @@ jwt-secret = /tests/static/keyfile [args] all.database.password = passwd +all.vector-index = true all.database.extended-names = true all.javascript.allow-admin-execute = true all.server.options-api = admin diff --git a/tests/test_index.py b/tests/test_index.py index 04708d9..c756b1e 100644 --- a/tests/test_index.py +++ b/tests/test_index.py @@ -8,7 +8,7 @@ IndexListError, IndexLoadError, ) -from tests.helpers import assert_raises, extract +from tests.helpers import assert_raises, extract, generate_doc_key def test_list_indexes(icol, bad_col): @@ -350,6 +350,27 @@ def test_add_mdi_index(icol, db_version): icol.delete_index(result["id"]) +def test_add_vector_index(col): + docs = [] + for i in range(100): + docs.append({"_key": generate_doc_key(), "x": [1] * 128}) + col.insert_many(docs) + result = col.add_index( + { + "type": "vector", + "fields": ["x"], + "name": "vector_index", + "params": { + "metric": "cosine", + "dimension": 128, + "nLists": 2, + }, + } + ) + assert result["name"] == "vector_index" + col.delete_index(result["id"]) + + def test_delete_index(icol, bad_col): old_indexes = set(extract("id", icol.indexes())) hash_index = {"type": "hash", "fields": ["attr1", "attr2"], "unique": True}