Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions arango/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions tests/static/cluster-3.12.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/static/single-3.12.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 22 additions & 1 deletion tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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}
Expand Down
Loading