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
35 changes: 35 additions & 0 deletions test/collection/test_config_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,41 @@ def test_collection_config_from_json_with_dropped_vector_index() -> None:
assert as_dict["vectorConfig"]["kept"]["vectorIndexType"] == VectorIndexType.HNSW.value


@pytest.mark.parametrize(
"multivector",
[
{"enabled": True, "aggregation": "maxSim"},
{
"enabled": True,
"aggregation": "maxSim",
"muvera": {"enabled": True, "ksim": 4, "dprojections": 16, "repetitions": 10},
},
],
)
def test_collection_config_to_dict_keeps_multivector(multivector: Dict[str, Any]) -> None:
"""A multi-vector index must round-trip in the shape the server accepts, or it is recreated as a regular index."""
schema = _schema_with_vector_config(
{
"colbert": {
"vectorizer": {"none": {}},
"vectorIndexType": "hnsw",
"vectorIndexConfig": {**HNSW_CONFIG, "multivector": multivector},
},
"regular": {
"vectorizer": {"none": {}},
"vectorIndexType": "hnsw",
"vectorIndexConfig": HNSW_CONFIG,
},
}
)

as_dict = _collection_config_from_json(schema).to_dict()

assert as_dict["vectorConfig"]["colbert"]["vectorIndexConfig"]["multivector"] == multivector
assert "multiVector" not in as_dict["vectorConfig"]["colbert"]["vectorIndexConfig"]
assert "multivector" not in as_dict["vectorConfig"]["regular"]["vectorIndexConfig"]


def test_collection_config_from_json_missing_vector_index_config_raises() -> None:
"""A non-dropped vector missing its vectorIndexConfig must fail fast, not parse as None."""
schema = _schema_with_vector_config(
Expand Down
5 changes: 5 additions & 0 deletions weaviate/collections/classes/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2137,6 +2137,11 @@ def to_dict(self) -> Dict[str, Any]:
out["sq"] = {**out.pop("quantizer"), "enabled": True}
elif isinstance(self.quantizer, _RQConfig):
out["rq"] = {**out.pop("quantizer"), "enabled": True}
if self.multi_vector is not None:
multi_vector = out.pop("multiVector")
out["multivector"] = {"enabled": True, "aggregation": multi_vector["aggregation"]}
if "encoding" in multi_vector:
out["multivector"]["muvera"] = multi_vector["encoding"]
return out


Expand Down
Loading