From 2bf26cabaa6d6ea4ba24a67b61ccdb6f4ac4ff13 Mon Sep 17 00:00:00 2001 From: songqing Date: Wed, 1 Apr 2026 11:53:47 +0800 Subject: [PATCH 1/3] fix: correct vector index type check from to --- python/zvec/model/collection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/zvec/model/collection.py b/python/zvec/model/collection.py index f7a12b437..a464b688d 100644 --- a/python/zvec/model/collection.py +++ b/python/zvec/model/collection.py @@ -136,7 +136,7 @@ def create_index( Raises: ValueError: If a vector index is applied to a non-vector field. """ - if index_param in _VECTOR_INDEX_TYPES and not self.schema.vector(field_name): + if isinstance(index_param, _VECTOR_INDEX_TYPES) and not self.schema.vector(field_name): supported_types = ", ".join(cls.__name__ for cls in _VECTOR_INDEX_TYPES) raise ValueError( f"Cannot apply vector index to non-vector field '{field_name}'. " From 8b639ab0fad7c70e42c4bd080795252af1309fdb Mon Sep 17 00:00:00 2001 From: songqing Date: Tue, 14 Apr 2026 11:16:47 +0800 Subject: [PATCH 2/3] fix lint --- python/zvec/model/collection.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/zvec/model/collection.py b/python/zvec/model/collection.py index a464b688d..998cecf93 100644 --- a/python/zvec/model/collection.py +++ b/python/zvec/model/collection.py @@ -136,7 +136,9 @@ def create_index( Raises: ValueError: If a vector index is applied to a non-vector field. """ - if isinstance(index_param, _VECTOR_INDEX_TYPES) and not self.schema.vector(field_name): + if isinstance(index_param, _VECTOR_INDEX_TYPES) and not self.schema.vector( + field_name + ): supported_types = ", ".join(cls.__name__ for cls in _VECTOR_INDEX_TYPES) raise ValueError( f"Cannot apply vector index to non-vector field '{field_name}'. " From 80d7a38a409bee81c899e58347afedfa56bef093 Mon Sep 17 00:00:00 2001 From: songqing Date: Tue, 14 Apr 2026 17:44:48 +0800 Subject: [PATCH 3/3] fix comment --- python/zvec/model/collection.py | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/python/zvec/model/collection.py b/python/zvec/model/collection.py index 998cecf93..fde364ce8 100644 --- a/python/zvec/model/collection.py +++ b/python/zvec/model/collection.py @@ -39,13 +39,6 @@ __all__ = ["Collection"] -_VECTOR_INDEX_TYPES = ( - HnswIndexParam, - HnswRabitqIndexParam, - IVFIndexParam, - FlatIndexParam, -) - class Collection: """Represents an opened collection in Zvec. @@ -133,17 +126,7 @@ def create_index( option (Optional[IndexOption], optional): Index creation options. Defaults to ``IndexOption()``. - Raises: - ValueError: If a vector index is applied to a non-vector field. """ - if isinstance(index_param, _VECTOR_INDEX_TYPES) and not self.schema.vector( - field_name - ): - supported_types = ", ".join(cls.__name__ for cls in _VECTOR_INDEX_TYPES) - raise ValueError( - f"Cannot apply vector index to non-vector field '{field_name}'. " - f"The field must be of vector type to use index types like {supported_types}." - ) self._obj.CreateIndex(field_name, index_param, option) self._schema = CollectionSchema._from_core(self._obj.Schema())