From 8957d61d70881b07073da54cd83059abdbfb5801 Mon Sep 17 00:00:00 2001 From: Roberto Esposito Date: Thu, 16 Oct 2025 18:56:29 +0200 Subject: [PATCH 01/18] add spfresh to python client --- weaviate/collections/classes/config.py | 20 ++++++- .../collections/classes/config_methods.py | 15 +++++ .../classes/config_named_vectors.py | 2 + .../classes/config_vector_index.py | 57 +++++++++++++++++++ .../collections/classes/config_vectors.py | 16 ++++++ weaviate/collections/config/async_.pyi | 4 +- weaviate/collections/config/executor.py | 4 ++ weaviate/collections/config/sync.pyi | 4 +- weaviate/outputs/config.py | 2 + 9 files changed, 120 insertions(+), 4 deletions(-) diff --git a/weaviate/collections/classes/config.py b/weaviate/collections/classes/config.py index 32009cee4..c3b580397 100644 --- a/weaviate/collections/classes/config.py +++ b/weaviate/collections/classes/config.py @@ -45,6 +45,7 @@ _VectorIndexConfigDynamicUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigHNSWUpdate, + _VectorIndexConfigSPFreshUpdate, _VectorIndexConfigUpdate, ) from weaviate.collections.classes.config_vector_index import ( @@ -1593,6 +1594,21 @@ def vector_index_type() -> str: VectorIndexConfigHNSW = _VectorIndexConfigHNSW +@dataclass +class _VectorIndexConfigSPFresh(_VectorIndexConfig): + distance_metric: VectorDistances + max_posting_size: int + min_posting_size: int + replicas: int + rng_factor: int + search_probe: int + centroids_index_type: str + + @staticmethod + def vector_index_type() -> str: + return VectorIndexType.SPFRESH.value + +VectorIndexConfigSPFresh = _VectorIndexConfigSPFresh @dataclass class _VectorIndexConfigFlat(_VectorIndexConfig): @@ -1667,7 +1683,7 @@ def to_dict(self) -> Dict[str, Any]: class _NamedVectorConfig(_ConfigBase): vectorizer: _NamedVectorizerConfig vector_index_config: Union[ - VectorIndexConfigHNSW, VectorIndexConfigFlat, VectorIndexConfigDynamic + VectorIndexConfigHNSW, VectorIndexConfigFlat, VectorIndexConfigDynamic, VectorIndexConfigSPFresh ] def to_dict(self) -> Dict: @@ -1692,7 +1708,7 @@ class _CollectionConfig(_ConfigBase): reranker_config: Optional[RerankerConfig] sharding_config: Optional[ShardingConfig] vector_index_config: Union[ - VectorIndexConfigHNSW, VectorIndexConfigFlat, VectorIndexConfigDynamic, None + VectorIndexConfigHNSW, VectorIndexConfigFlat, VectorIndexConfigDynamic, VectorIndexConfigSPFresh, None ] vector_index_type: Optional[VectorIndexType] vectorizer_config: Optional[VectorizerConfig] diff --git a/weaviate/collections/classes/config_methods.py b/weaviate/collections/classes/config_methods.py index 6b815ba24..d5845e86a 100644 --- a/weaviate/collections/classes/config_methods.py +++ b/weaviate/collections/classes/config_methods.py @@ -39,6 +39,7 @@ _VectorIndexConfigDynamic, _VectorIndexConfigFlat, _VectorIndexConfigHNSW, + _VectorIndexConfigSPFresh, _VectorizerConfig, ) @@ -210,6 +211,18 @@ def __get_hnsw_config(config: Dict[str, Any]) -> _VectorIndexConfigHNSW: multi_vector=__get_multivector(config), ) +def __get_spfresh_config(config: Dict[str, Any]) -> _VectorIndexConfigSPFresh: + quantizer = __get_quantizer_config(config) + return _VectorIndexConfigSPFresh( + distance_metric=VectorDistances(config.get("distance")), + max_posting_size=config["maxPostingSize"], + min_posting_size=config["minPostingSize"], + replicas=config["replicas"], + rng_factor=config["rngFactor"], + search_probe=config["searchProbe"], + centroids_index_type=config["centroidsIndexType"], + quantizer=quantizer, + ) def __get_flat_config(config: Dict[str, Any]) -> _VectorIndexConfigFlat: quantizer = __get_quantizer_config(config) @@ -237,6 +250,8 @@ def __get_vector_index_config( hnsw=__get_hnsw_config(schema["vectorIndexConfig"]["hnsw"]), flat=__get_flat_config(schema["vectorIndexConfig"]["flat"]), ) + elif schema["vectorIndexType"] == "spfresh": + return __get_spfresh_config(schema["vectorIndexConfig"]) else: return None diff --git a/weaviate/collections/classes/config_named_vectors.py b/weaviate/collections/classes/config_named_vectors.py index 3e6cb641e..83f927083 100644 --- a/weaviate/collections/classes/config_named_vectors.py +++ b/weaviate/collections/classes/config_named_vectors.py @@ -15,6 +15,7 @@ _VectorIndexConfigDynamicUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigHNSWUpdate, + _VectorIndexConfigSPFreshUpdate, _VectorIndexConfigUpdate, ) from weaviate.collections.classes.config_vectorizers import ( @@ -1330,6 +1331,7 @@ def update( *, vector_index_config: Union[ _VectorIndexConfigHNSWUpdate, + _VectorIndexConfigSPFreshUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigDynamicUpdate, ], diff --git a/weaviate/collections/classes/config_vector_index.py b/weaviate/collections/classes/config_vector_index.py index ce70c9a0f..87ffe7017 100644 --- a/weaviate/collections/classes/config_vector_index.py +++ b/weaviate/collections/classes/config_vector_index.py @@ -34,11 +34,14 @@ class VectorIndexType(str, Enum): Attributes: HNSW: Hierarchical Navigable Small World (HNSW) index. FLAT: Flat index. + DYNAMIC: Dynamic index. + SPFRESH: SPFRESH index. """ HNSW = "hnsw" FLAT = "flat" DYNAMIC = "dynamic" + SPFRESH = "spfresh" class _MultiVectorConfigCreateBase(_ConfigCreateModel): @@ -127,6 +130,19 @@ def vector_index_type() -> VectorIndexType: return VectorIndexType.HNSW +class _VectorIndexConfigSPFreshCreate(_VectorIndexConfigCreate): + maxPostingSize: Optional[int] + minPostingSize: Optional[int] + replicas: Optional[int] + rngFactor: Optional[int] + searchProbe: Optional[int] + centroidsIndexType: Optional[str] + + @staticmethod + def vector_index_type() -> VectorIndexType: + return VectorIndexType.SPFRESH + + class _VectorIndexConfigFlatCreate(_VectorIndexConfigCreate): vectorCacheMaxObjects: Optional[int] @@ -149,6 +165,17 @@ def vector_index_type() -> VectorIndexType: return VectorIndexType.HNSW +class _VectorIndexConfigSPFreshUpdate(_VectorIndexConfigUpdate): + maxPostingSize: Optional[int] + minPostingSize: Optional[int] + rngFactor: Optional[int] + searchProbe: Optional[int] + + @staticmethod + def vector_index_type() -> VectorIndexType: + return VectorIndexType.SPFRESH + + class _VectorIndexConfigFlatUpdate(_VectorIndexConfigUpdate): vectorCacheMaxObjects: Optional[int] @@ -564,6 +591,36 @@ def hnsw( multivector=multi_vector, ) + @staticmethod + def spfresh( + distance_metric: Optional[VectorDistances] = None, + max_posting_size: Optional[int] = None, + min_posting_size: Optional[int] = None, + replicas: Optional[int] = None, + rng_factor: Optional[int] = None, + search_probe: Optional[int] = None, + centroids_index_type: Optional[str] = None, + quantizer: Optional[_QuantizerConfigCreate] = None, + ) -> _VectorIndexConfigSPFreshCreate: + """Create a `_VectorIndexConfigSPFreshCreate` object to be used when defining the SPFresh vector index configuration of Weaviate. + + Use this method when defining the `vector_index_config` argument in `collections.create()`. + + Args: + See [the docs](https://weaviate.io/developers/weaviate/configuration/indexes#how-to-configure-spfresh) for a more detailed view! + """ + return _VectorIndexConfigSPFreshCreate( + distance=distance_metric, + maxPostingSize=max_posting_size, + minPostingSize=min_posting_size, + replicas=replicas, + rngFactor=rng_factor, + searchProbe=search_probe, + centroidsIndexType=centroids_index_type, + quantizer=quantizer, + multivector=None, + ) + @staticmethod def flat( distance_metric: Optional[VectorDistances] = None, diff --git a/weaviate/collections/classes/config_vectors.py b/weaviate/collections/classes/config_vectors.py index 9dd4dc91c..fff3d300e 100644 --- a/weaviate/collections/classes/config_vectors.py +++ b/weaviate/collections/classes/config_vectors.py @@ -20,6 +20,8 @@ _VectorIndexConfigFlatUpdate, _VectorIndexConfigHNSWCreate, _VectorIndexConfigHNSWUpdate, + _VectorIndexConfigSPFreshCreate, + _VectorIndexConfigSPFreshUpdate, _VectorIndexConfigUpdate, ) from weaviate.collections.classes.config_vectorizers import ( @@ -126,6 +128,19 @@ def __hnsw( multivector=multivector, ) + @staticmethod + def __spfresh(*, quantizer: Optional[_QuantizerConfigCreate]) -> _VectorIndexConfigSPFreshCreate: + return _VectorIndexConfigSPFreshCreate( + distance_metric=None, + maxPostingSize=None, + minPostingSize=None, + replicas=None, + rngFactor=None, + searchProbe=None, + centroidsIndexType=None, + quantizer=quantizer, + ) + @staticmethod def __flat(*, quantizer: Optional[_QuantizerConfigCreate]) -> _VectorIndexConfigFlatCreate: return _VectorIndexConfigFlatCreate( @@ -1504,6 +1519,7 @@ def update( name: Optional[str] = None, vector_index_config: Union[ _VectorIndexConfigHNSWUpdate, + _VectorIndexConfigSPFreshUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigDynamicUpdate, ], diff --git a/weaviate/collections/config/async_.pyi b/weaviate/collections/config/async_.pyi index 9fcfefdb3..22e6c2021 100644 --- a/weaviate/collections/config/async_.pyi +++ b/weaviate/collections/config/async_.pyi @@ -21,6 +21,7 @@ from weaviate.collections.classes.config import ( _VectorConfigUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigHNSWUpdate, + _VectorIndexConfigSPFreshUpdate, ) from weaviate.collections.classes.config_vector_index import _VectorIndexConfigDynamicUpdate from weaviate.connect.v4 import ConnectionAsync @@ -45,13 +46,14 @@ class _ConfigCollectionAsync(_ConfigCollectionExecutor[ConnectionAsync]): multi_tenancy_config: Optional[_MultiTenancyConfigUpdate] = None, replication_config: Optional[_ReplicationConfigUpdate] = None, vector_index_config: Optional[ - Union[_VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate] + Union[_VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigSPFreshUpdate] ] = None, vectorizer_config: Optional[ Union[ _VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigDynamicUpdate, + _VectorIndexConfigSPFreshUpdate, List[_NamedVectorConfigUpdate], ] ] = None, diff --git a/weaviate/collections/config/executor.py b/weaviate/collections/config/executor.py index e5772b76a..6aa5de917 100644 --- a/weaviate/collections/config/executor.py +++ b/weaviate/collections/config/executor.py @@ -38,6 +38,7 @@ _VectorConfigUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigHNSWUpdate, + _VectorIndexConfigSPFreshUpdate, ) from weaviate.collections.classes.config_methods import ( _collection_config_from_json, @@ -134,6 +135,7 @@ def update( Union[ _VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, + _VectorIndexConfigSPFreshUpdate, ] ] = None, vectorizer_config: Optional[ @@ -141,6 +143,7 @@ def update( _VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigDynamicUpdate, + _VectorIndexConfigSPFreshUpdate, List[_NamedVectorConfigUpdate], ] ] = None, @@ -184,6 +187,7 @@ def update( _VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigDynamicUpdate, + _VectorIndexConfigSPFreshUpdate, ), ): _Warnings.vectorizer_config_in_config_update() diff --git a/weaviate/collections/config/sync.pyi b/weaviate/collections/config/sync.pyi index 89f37615e..29aeb9c94 100644 --- a/weaviate/collections/config/sync.pyi +++ b/weaviate/collections/config/sync.pyi @@ -21,6 +21,7 @@ from weaviate.collections.classes.config import ( _VectorConfigUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigHNSWUpdate, + _VectorIndexConfigSPFreshUpdate, ) from weaviate.collections.classes.config_vector_index import _VectorIndexConfigDynamicUpdate from weaviate.connect.v4 import ConnectionSync @@ -43,13 +44,14 @@ class _ConfigCollection(_ConfigCollectionExecutor[ConnectionSync]): multi_tenancy_config: Optional[_MultiTenancyConfigUpdate] = None, replication_config: Optional[_ReplicationConfigUpdate] = None, vector_index_config: Optional[ - Union[_VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate] + Union[_VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigSPFreshUpdate] ] = None, vectorizer_config: Optional[ Union[ _VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigDynamicUpdate, + _VectorIndexConfigSPFreshUpdate, List[_NamedVectorConfigUpdate], ] ] = None, diff --git a/weaviate/outputs/config.py b/weaviate/outputs/config.py index d6c8ed230..5f0e236f3 100644 --- a/weaviate/outputs/config.py +++ b/weaviate/outputs/config.py @@ -23,6 +23,7 @@ VectorDistances, VectorIndexConfigFlat, VectorIndexConfigHNSW, + VectorIndexConfigSPFresh, VectorIndexType, VectorizerConfig, Vectorizers, @@ -52,6 +53,7 @@ "ShardTypes", "VectorDistances", "VectorIndexConfigHNSW", + "VectorIndexConfigSPFresh", "VectorIndexConfigFlat", "VectorIndexType", "Vectorizers", From f1abc27abbbc9f672e157b67f46578fbcf9e2165 Mon Sep 17 00:00:00 2001 From: Roberto Esposito Date: Fri, 17 Oct 2025 12:09:49 +0200 Subject: [PATCH 02/18] add enum for centroids index type in spfresh --- weaviate/classes/config.py | 2 ++ weaviate/collections/classes/config.py | 3 ++- weaviate/collections/classes/config_methods.py | 7 ++++++- .../collections/classes/config_vector_index.py | 16 ++++++++++++++-- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/weaviate/classes/config.py b/weaviate/classes/config.py index 651818de3..a214e6811 100644 --- a/weaviate/classes/config.py +++ b/weaviate/classes/config.py @@ -17,6 +17,7 @@ from weaviate.collections.classes.config_vector_index import ( MultiVectorAggregation, VectorFilterStrategy, + VectorCentroidsIndexType ) from weaviate.collections.classes.config_vectorizers import Multi2VecField, Vectorizers from weaviate.connect.integrations import Integrations @@ -41,4 +42,5 @@ "Vectorizers", "VectorDistances", "VectorFilterStrategy", + "VectorCentroidsIndexType", ] diff --git a/weaviate/collections/classes/config.py b/weaviate/collections/classes/config.py index c3b580397..abdded8fa 100644 --- a/weaviate/collections/classes/config.py +++ b/weaviate/collections/classes/config.py @@ -35,6 +35,7 @@ PQEncoderDistribution, PQEncoderType, VectorFilterStrategy, + VectorCentroidsIndexType, _BQConfigUpdate, _PQConfigUpdate, _PQEncoderConfigUpdate, @@ -1602,7 +1603,7 @@ class _VectorIndexConfigSPFresh(_VectorIndexConfig): replicas: int rng_factor: int search_probe: int - centroids_index_type: str + centroids_index_type: VectorCentroidsIndexType @staticmethod def vector_index_type() -> str: diff --git a/weaviate/collections/classes/config_methods.py b/weaviate/collections/classes/config_methods.py index d5845e86a..ec5692883 100644 --- a/weaviate/collections/classes/config_methods.py +++ b/weaviate/collections/classes/config_methods.py @@ -12,6 +12,7 @@ VectorDistances, VectorFilterStrategy, VectorIndexType, + VectorCentroidsIndexType, Vectorizers, _BM25Config, _BQConfig, @@ -220,7 +221,11 @@ def __get_spfresh_config(config: Dict[str, Any]) -> _VectorIndexConfigSPFresh: replicas=config["replicas"], rng_factor=config["rngFactor"], search_probe=config["searchProbe"], - centroids_index_type=config["centroidsIndexType"], + centroids_index_type=( + VectorCentroidsIndexType(config["centroidsIndexType"]) + if "centroidsIndexType" in config + else VectorCentroidsIndexType.HNSW + ), quantizer=quantizer, ) diff --git a/weaviate/collections/classes/config_vector_index.py b/weaviate/collections/classes/config_vector_index.py index 87ffe7017..7d98e9cb4 100644 --- a/weaviate/collections/classes/config_vector_index.py +++ b/weaviate/collections/classes/config_vector_index.py @@ -44,6 +44,18 @@ class VectorIndexType(str, Enum): SPFRESH = "spfresh" +class VectorCentroidsIndexType(str, Enum): + """The available index type that can be used for centroids in SPFresh. + + Attributes: + HNSW: Hierarchical Navigable Small World (HNSW) index. + FLAT: flat index. + """ + + HNSW = "hnsw" + FLAT = "bruteforce" + + class _MultiVectorConfigCreateBase(_ConfigCreateModel): enabled: bool = Field(default=True) @@ -136,7 +148,7 @@ class _VectorIndexConfigSPFreshCreate(_VectorIndexConfigCreate): replicas: Optional[int] rngFactor: Optional[int] searchProbe: Optional[int] - centroidsIndexType: Optional[str] + centroidsIndexType: Optional[VectorCentroidsIndexType] @staticmethod def vector_index_type() -> VectorIndexType: @@ -599,7 +611,7 @@ def spfresh( replicas: Optional[int] = None, rng_factor: Optional[int] = None, search_probe: Optional[int] = None, - centroids_index_type: Optional[str] = None, + centroids_index_type: Optional[VectorCentroidsIndexType] = None, quantizer: Optional[_QuantizerConfigCreate] = None, ) -> _VectorIndexConfigSPFreshCreate: """Create a `_VectorIndexConfigSPFreshCreate` object to be used when defining the SPFresh vector index configuration of Weaviate. From 9518b8f708f66ca17aff2439b410470d64dfba7a Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez Date: Mon, 17 Nov 2025 16:58:59 +0100 Subject: [PATCH 03/18] Add missing init parameter for spfresh --- weaviate/collections/classes/config_methods.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/weaviate/collections/classes/config_methods.py b/weaviate/collections/classes/config_methods.py index ec5692883..6068bbde1 100644 --- a/weaviate/collections/classes/config_methods.py +++ b/weaviate/collections/classes/config_methods.py @@ -227,6 +227,7 @@ def __get_spfresh_config(config: Dict[str, Any]) -> _VectorIndexConfigSPFresh: else VectorCentroidsIndexType.HNSW ), quantizer=quantizer, + multi_vector=__get_multivector(config), ) def __get_flat_config(config: Dict[str, Any]) -> _VectorIndexConfigFlat: @@ -241,7 +242,7 @@ def __get_flat_config(config: Dict[str, Any]) -> _VectorIndexConfigFlat: def __get_vector_index_config( schema: Dict[str, Any], -) -> Union[_VectorIndexConfigHNSW, _VectorIndexConfigFlat, _VectorIndexConfigDynamic, None]: +) -> Union[_VectorIndexConfigHNSW, _VectorIndexConfigFlat, _VectorIndexConfigDynamic, _VectorIndexConfigSPFresh, None]: if "vectorIndexConfig" not in schema: return None if schema["vectorIndexType"] == "hnsw": From 896c3339ffc2d65a09bbf130262e0d1002ca9f27 Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez Date: Mon, 17 Nov 2025 17:05:44 +0100 Subject: [PATCH 04/18] Fix spfresh params in config of the class --- weaviate/collections/classes/config.py | 1 - weaviate/collections/classes/config_vectors.py | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/weaviate/collections/classes/config.py b/weaviate/collections/classes/config.py index abdded8fa..a6500112d 100644 --- a/weaviate/collections/classes/config.py +++ b/weaviate/collections/classes/config.py @@ -46,7 +46,6 @@ _VectorIndexConfigDynamicUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigHNSWUpdate, - _VectorIndexConfigSPFreshUpdate, _VectorIndexConfigUpdate, ) from weaviate.collections.classes.config_vector_index import ( diff --git a/weaviate/collections/classes/config_vectors.py b/weaviate/collections/classes/config_vectors.py index fff3d300e..690c4c0e4 100644 --- a/weaviate/collections/classes/config_vectors.py +++ b/weaviate/collections/classes/config_vectors.py @@ -131,7 +131,6 @@ def __hnsw( @staticmethod def __spfresh(*, quantizer: Optional[_QuantizerConfigCreate]) -> _VectorIndexConfigSPFreshCreate: return _VectorIndexConfigSPFreshCreate( - distance_metric=None, maxPostingSize=None, minPostingSize=None, replicas=None, @@ -139,6 +138,8 @@ def __spfresh(*, quantizer: Optional[_QuantizerConfigCreate]) -> _VectorIndexCon searchProbe=None, centroidsIndexType=None, quantizer=quantizer, + multivector=None, + distance=None, ) @staticmethod From 59a1317b2cef670a3326dc6051ef6ac6504c7770 Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez Date: Mon, 17 Nov 2025 17:47:36 +0100 Subject: [PATCH 05/18] Add missing multivector param for spfresh --- weaviate/collections/classes/config_vector_index.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/weaviate/collections/classes/config_vector_index.py b/weaviate/collections/classes/config_vector_index.py index 7d98e9cb4..836ff70d7 100644 --- a/weaviate/collections/classes/config_vector_index.py +++ b/weaviate/collections/classes/config_vector_index.py @@ -613,6 +613,7 @@ def spfresh( search_probe: Optional[int] = None, centroids_index_type: Optional[VectorCentroidsIndexType] = None, quantizer: Optional[_QuantizerConfigCreate] = None, + multi_vector: Optional[_MultiVectorConfigCreate] = None, ) -> _VectorIndexConfigSPFreshCreate: """Create a `_VectorIndexConfigSPFreshCreate` object to be used when defining the SPFresh vector index configuration of Weaviate. @@ -630,7 +631,7 @@ def spfresh( searchProbe=search_probe, centroidsIndexType=centroids_index_type, quantizer=quantizer, - multivector=None, + multivector=multi_vector, ) @staticmethod From f07d50d2f6887ea0365d116c6ac04fd8f4646d23 Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez Date: Tue, 18 Nov 2025 11:36:08 +0100 Subject: [PATCH 06/18] Fix multivector --- weaviate/collections/classes/config.py | 1 + weaviate/collections/classes/config_methods.py | 2 +- weaviate/collections/classes/config_vector_index.py | 1 + weaviate/collections/classes/config_vectors.py | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/weaviate/collections/classes/config.py b/weaviate/collections/classes/config.py index a6500112d..abdded8fa 100644 --- a/weaviate/collections/classes/config.py +++ b/weaviate/collections/classes/config.py @@ -46,6 +46,7 @@ _VectorIndexConfigDynamicUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigHNSWUpdate, + _VectorIndexConfigSPFreshUpdate, _VectorIndexConfigUpdate, ) from weaviate.collections.classes.config_vector_index import ( diff --git a/weaviate/collections/classes/config_methods.py b/weaviate/collections/classes/config_methods.py index 6068bbde1..b59967afa 100644 --- a/weaviate/collections/classes/config_methods.py +++ b/weaviate/collections/classes/config_methods.py @@ -227,7 +227,7 @@ def __get_spfresh_config(config: Dict[str, Any]) -> _VectorIndexConfigSPFresh: else VectorCentroidsIndexType.HNSW ), quantizer=quantizer, - multi_vector=__get_multivector(config), + multi_vector=None, ) def __get_flat_config(config: Dict[str, Any]) -> _VectorIndexConfigFlat: diff --git a/weaviate/collections/classes/config_vector_index.py b/weaviate/collections/classes/config_vector_index.py index 836ff70d7..e81e435af 100644 --- a/weaviate/collections/classes/config_vector_index.py +++ b/weaviate/collections/classes/config_vector_index.py @@ -614,6 +614,7 @@ def spfresh( centroids_index_type: Optional[VectorCentroidsIndexType] = None, quantizer: Optional[_QuantizerConfigCreate] = None, multi_vector: Optional[_MultiVectorConfigCreate] = None, + ) -> _VectorIndexConfigSPFreshCreate: """Create a `_VectorIndexConfigSPFreshCreate` object to be used when defining the SPFresh vector index configuration of Weaviate. diff --git a/weaviate/collections/classes/config_vectors.py b/weaviate/collections/classes/config_vectors.py index 690c4c0e4..b8cf7eb30 100644 --- a/weaviate/collections/classes/config_vectors.py +++ b/weaviate/collections/classes/config_vectors.py @@ -131,6 +131,7 @@ def __hnsw( @staticmethod def __spfresh(*, quantizer: Optional[_QuantizerConfigCreate]) -> _VectorIndexConfigSPFreshCreate: return _VectorIndexConfigSPFreshCreate( + distance_metric=None, maxPostingSize=None, minPostingSize=None, replicas=None, From 2bcd33ce7328c0d75ec55244c7276e9b55966b7a Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez Date: Mon, 24 Nov 2025 16:34:58 +0100 Subject: [PATCH 07/18] Fix update spfresh method --- weaviate/collections/classes/config.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/weaviate/collections/classes/config.py b/weaviate/collections/classes/config.py index abdded8fa..f7afe5824 100644 --- a/weaviate/collections/classes/config.py +++ b/weaviate/collections/classes/config.py @@ -2349,6 +2349,29 @@ def dynamic( quantizer=quantizer, ) + @staticmethod + def spfresh( + max_posting_size: Optional[int] = None, + min_posting_size: Optional[int] = None, + rng_factor: Optional[int] = None, + search_probe: Optional[int] = None, + quantizer: Optional[_RQConfigUpdate] = None, + ) -> _VectorIndexConfigSPFreshUpdate: + """Create an `_VectorIndexConfigSPFreshUpdate` object to update the configuration of the SPFresh vector index. + + Use this method when defining the `vectorizer_config` argument in `collection.update()`. + + Args: + See [the docs](https://weaviate.io/developers/weaviate/configuration/indexes#configure-the-inverted-index) for a more detailed view! + """ # noqa: D417 (missing argument descriptions in the docstring) + return _VectorIndexConfigSPFreshUpdate( + maxPostingSize=max_posting_size, + minPostingSize=min_posting_size, + rngFactor=rng_factor, + searchProbe=search_probe, + quantizer=quantizer, + ) + class Reconfigure: """Use this factory class to generate the correct `xxxConfig` object for use when using the `collection.update()` method. From c188305f59b5d3cb3c7b50bfe84a06f3215b586b Mon Sep 17 00:00:00 2001 From: Roberto Esposito Date: Fri, 28 Nov 2025 14:29:28 +0100 Subject: [PATCH 08/18] remove centroids index type --- weaviate/collections/classes/config.py | 2 -- weaviate/collections/classes/config_methods.py | 6 ------ .../collections/classes/config_vector_index.py | 15 --------------- weaviate/collections/classes/config_vectors.py | 1 - 4 files changed, 24 deletions(-) diff --git a/weaviate/collections/classes/config.py b/weaviate/collections/classes/config.py index f7afe5824..0cdc29127 100644 --- a/weaviate/collections/classes/config.py +++ b/weaviate/collections/classes/config.py @@ -35,7 +35,6 @@ PQEncoderDistribution, PQEncoderType, VectorFilterStrategy, - VectorCentroidsIndexType, _BQConfigUpdate, _PQConfigUpdate, _PQEncoderConfigUpdate, @@ -1603,7 +1602,6 @@ class _VectorIndexConfigSPFresh(_VectorIndexConfig): replicas: int rng_factor: int search_probe: int - centroids_index_type: VectorCentroidsIndexType @staticmethod def vector_index_type() -> str: diff --git a/weaviate/collections/classes/config_methods.py b/weaviate/collections/classes/config_methods.py index b59967afa..f8179192f 100644 --- a/weaviate/collections/classes/config_methods.py +++ b/weaviate/collections/classes/config_methods.py @@ -12,7 +12,6 @@ VectorDistances, VectorFilterStrategy, VectorIndexType, - VectorCentroidsIndexType, Vectorizers, _BM25Config, _BQConfig, @@ -221,11 +220,6 @@ def __get_spfresh_config(config: Dict[str, Any]) -> _VectorIndexConfigSPFresh: replicas=config["replicas"], rng_factor=config["rngFactor"], search_probe=config["searchProbe"], - centroids_index_type=( - VectorCentroidsIndexType(config["centroidsIndexType"]) - if "centroidsIndexType" in config - else VectorCentroidsIndexType.HNSW - ), quantizer=quantizer, multi_vector=None, ) diff --git a/weaviate/collections/classes/config_vector_index.py b/weaviate/collections/classes/config_vector_index.py index e81e435af..2ef6b8ad1 100644 --- a/weaviate/collections/classes/config_vector_index.py +++ b/weaviate/collections/classes/config_vector_index.py @@ -44,18 +44,6 @@ class VectorIndexType(str, Enum): SPFRESH = "spfresh" -class VectorCentroidsIndexType(str, Enum): - """The available index type that can be used for centroids in SPFresh. - - Attributes: - HNSW: Hierarchical Navigable Small World (HNSW) index. - FLAT: flat index. - """ - - HNSW = "hnsw" - FLAT = "bruteforce" - - class _MultiVectorConfigCreateBase(_ConfigCreateModel): enabled: bool = Field(default=True) @@ -148,7 +136,6 @@ class _VectorIndexConfigSPFreshCreate(_VectorIndexConfigCreate): replicas: Optional[int] rngFactor: Optional[int] searchProbe: Optional[int] - centroidsIndexType: Optional[VectorCentroidsIndexType] @staticmethod def vector_index_type() -> VectorIndexType: @@ -611,7 +598,6 @@ def spfresh( replicas: Optional[int] = None, rng_factor: Optional[int] = None, search_probe: Optional[int] = None, - centroids_index_type: Optional[VectorCentroidsIndexType] = None, quantizer: Optional[_QuantizerConfigCreate] = None, multi_vector: Optional[_MultiVectorConfigCreate] = None, @@ -630,7 +616,6 @@ def spfresh( replicas=replicas, rngFactor=rng_factor, searchProbe=search_probe, - centroidsIndexType=centroids_index_type, quantizer=quantizer, multivector=multi_vector, ) diff --git a/weaviate/collections/classes/config_vectors.py b/weaviate/collections/classes/config_vectors.py index b8cf7eb30..e78af42aa 100644 --- a/weaviate/collections/classes/config_vectors.py +++ b/weaviate/collections/classes/config_vectors.py @@ -137,7 +137,6 @@ def __spfresh(*, quantizer: Optional[_QuantizerConfigCreate]) -> _VectorIndexCon replicas=None, rngFactor=None, searchProbe=None, - centroidsIndexType=None, quantizer=quantizer, multivector=None, distance=None, From fdefaa4761b2534a816290ec9c73dbbf2e8c0be9 Mon Sep 17 00:00:00 2001 From: Roberto Esposito Date: Thu, 16 Oct 2025 18:56:29 +0200 Subject: [PATCH 09/18] add spfresh to python client --- weaviate/collections/classes/config.py | 20 ++++++- .../collections/classes/config_methods.py | 15 +++++ .../classes/config_named_vectors.py | 2 + .../classes/config_vector_index.py | 57 +++++++++++++++++++ .../collections/classes/config_vectors.py | 16 ++++++ weaviate/collections/config/async_.pyi | 4 +- weaviate/collections/config/executor.py | 4 ++ weaviate/collections/config/sync.pyi | 4 +- weaviate/outputs/config.py | 2 + 9 files changed, 120 insertions(+), 4 deletions(-) diff --git a/weaviate/collections/classes/config.py b/weaviate/collections/classes/config.py index ae6db911a..703b513a6 100644 --- a/weaviate/collections/classes/config.py +++ b/weaviate/collections/classes/config.py @@ -45,6 +45,7 @@ _VectorIndexConfigDynamicUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigHNSWUpdate, + _VectorIndexConfigSPFreshUpdate, _VectorIndexConfigUpdate, ) from weaviate.collections.classes.config_vector_index import ( @@ -1886,6 +1887,21 @@ def vector_index_type() -> str: VectorIndexConfigHNSW = _VectorIndexConfigHNSW +@dataclass +class _VectorIndexConfigSPFresh(_VectorIndexConfig): + distance_metric: VectorDistances + max_posting_size: int + min_posting_size: int + replicas: int + rng_factor: int + search_probe: int + centroids_index_type: str + + @staticmethod + def vector_index_type() -> str: + return VectorIndexType.SPFRESH.value + +VectorIndexConfigSPFresh = _VectorIndexConfigSPFresh @dataclass class _VectorIndexConfigFlat(_VectorIndexConfig): @@ -1960,7 +1976,7 @@ def to_dict(self) -> Dict[str, Any]: class _NamedVectorConfig(_ConfigBase): vectorizer: _NamedVectorizerConfig vector_index_config: Union[ - VectorIndexConfigHNSW, VectorIndexConfigFlat, VectorIndexConfigDynamic + VectorIndexConfigHNSW, VectorIndexConfigFlat, VectorIndexConfigDynamic, VectorIndexConfigSPFresh ] def to_dict(self) -> Dict: @@ -1985,7 +2001,7 @@ class _CollectionConfig(_ConfigBase): reranker_config: Optional[RerankerConfig] sharding_config: Optional[ShardingConfig] vector_index_config: Union[ - VectorIndexConfigHNSW, VectorIndexConfigFlat, VectorIndexConfigDynamic, None + VectorIndexConfigHNSW, VectorIndexConfigFlat, VectorIndexConfigDynamic, VectorIndexConfigSPFresh, None ] vector_index_type: Optional[VectorIndexType] vectorizer_config: Optional[VectorizerConfig] diff --git a/weaviate/collections/classes/config_methods.py b/weaviate/collections/classes/config_methods.py index 6b815ba24..d5845e86a 100644 --- a/weaviate/collections/classes/config_methods.py +++ b/weaviate/collections/classes/config_methods.py @@ -39,6 +39,7 @@ _VectorIndexConfigDynamic, _VectorIndexConfigFlat, _VectorIndexConfigHNSW, + _VectorIndexConfigSPFresh, _VectorizerConfig, ) @@ -210,6 +211,18 @@ def __get_hnsw_config(config: Dict[str, Any]) -> _VectorIndexConfigHNSW: multi_vector=__get_multivector(config), ) +def __get_spfresh_config(config: Dict[str, Any]) -> _VectorIndexConfigSPFresh: + quantizer = __get_quantizer_config(config) + return _VectorIndexConfigSPFresh( + distance_metric=VectorDistances(config.get("distance")), + max_posting_size=config["maxPostingSize"], + min_posting_size=config["minPostingSize"], + replicas=config["replicas"], + rng_factor=config["rngFactor"], + search_probe=config["searchProbe"], + centroids_index_type=config["centroidsIndexType"], + quantizer=quantizer, + ) def __get_flat_config(config: Dict[str, Any]) -> _VectorIndexConfigFlat: quantizer = __get_quantizer_config(config) @@ -237,6 +250,8 @@ def __get_vector_index_config( hnsw=__get_hnsw_config(schema["vectorIndexConfig"]["hnsw"]), flat=__get_flat_config(schema["vectorIndexConfig"]["flat"]), ) + elif schema["vectorIndexType"] == "spfresh": + return __get_spfresh_config(schema["vectorIndexConfig"]) else: return None diff --git a/weaviate/collections/classes/config_named_vectors.py b/weaviate/collections/classes/config_named_vectors.py index bc1d27cd7..8cc86c484 100644 --- a/weaviate/collections/classes/config_named_vectors.py +++ b/weaviate/collections/classes/config_named_vectors.py @@ -15,6 +15,7 @@ _VectorIndexConfigDynamicUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigHNSWUpdate, + _VectorIndexConfigSPFreshUpdate, _VectorIndexConfigUpdate, ) from weaviate.collections.classes.config_vectorizers import ( @@ -1338,6 +1339,7 @@ def update( *, vector_index_config: Union[ _VectorIndexConfigHNSWUpdate, + _VectorIndexConfigSPFreshUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigDynamicUpdate, ], diff --git a/weaviate/collections/classes/config_vector_index.py b/weaviate/collections/classes/config_vector_index.py index ce70c9a0f..87ffe7017 100644 --- a/weaviate/collections/classes/config_vector_index.py +++ b/weaviate/collections/classes/config_vector_index.py @@ -34,11 +34,14 @@ class VectorIndexType(str, Enum): Attributes: HNSW: Hierarchical Navigable Small World (HNSW) index. FLAT: Flat index. + DYNAMIC: Dynamic index. + SPFRESH: SPFRESH index. """ HNSW = "hnsw" FLAT = "flat" DYNAMIC = "dynamic" + SPFRESH = "spfresh" class _MultiVectorConfigCreateBase(_ConfigCreateModel): @@ -127,6 +130,19 @@ def vector_index_type() -> VectorIndexType: return VectorIndexType.HNSW +class _VectorIndexConfigSPFreshCreate(_VectorIndexConfigCreate): + maxPostingSize: Optional[int] + minPostingSize: Optional[int] + replicas: Optional[int] + rngFactor: Optional[int] + searchProbe: Optional[int] + centroidsIndexType: Optional[str] + + @staticmethod + def vector_index_type() -> VectorIndexType: + return VectorIndexType.SPFRESH + + class _VectorIndexConfigFlatCreate(_VectorIndexConfigCreate): vectorCacheMaxObjects: Optional[int] @@ -149,6 +165,17 @@ def vector_index_type() -> VectorIndexType: return VectorIndexType.HNSW +class _VectorIndexConfigSPFreshUpdate(_VectorIndexConfigUpdate): + maxPostingSize: Optional[int] + minPostingSize: Optional[int] + rngFactor: Optional[int] + searchProbe: Optional[int] + + @staticmethod + def vector_index_type() -> VectorIndexType: + return VectorIndexType.SPFRESH + + class _VectorIndexConfigFlatUpdate(_VectorIndexConfigUpdate): vectorCacheMaxObjects: Optional[int] @@ -564,6 +591,36 @@ def hnsw( multivector=multi_vector, ) + @staticmethod + def spfresh( + distance_metric: Optional[VectorDistances] = None, + max_posting_size: Optional[int] = None, + min_posting_size: Optional[int] = None, + replicas: Optional[int] = None, + rng_factor: Optional[int] = None, + search_probe: Optional[int] = None, + centroids_index_type: Optional[str] = None, + quantizer: Optional[_QuantizerConfigCreate] = None, + ) -> _VectorIndexConfigSPFreshCreate: + """Create a `_VectorIndexConfigSPFreshCreate` object to be used when defining the SPFresh vector index configuration of Weaviate. + + Use this method when defining the `vector_index_config` argument in `collections.create()`. + + Args: + See [the docs](https://weaviate.io/developers/weaviate/configuration/indexes#how-to-configure-spfresh) for a more detailed view! + """ + return _VectorIndexConfigSPFreshCreate( + distance=distance_metric, + maxPostingSize=max_posting_size, + minPostingSize=min_posting_size, + replicas=replicas, + rngFactor=rng_factor, + searchProbe=search_probe, + centroidsIndexType=centroids_index_type, + quantizer=quantizer, + multivector=None, + ) + @staticmethod def flat( distance_metric: Optional[VectorDistances] = None, diff --git a/weaviate/collections/classes/config_vectors.py b/weaviate/collections/classes/config_vectors.py index 64d11b100..a2beae6bb 100644 --- a/weaviate/collections/classes/config_vectors.py +++ b/weaviate/collections/classes/config_vectors.py @@ -20,6 +20,8 @@ _VectorIndexConfigFlatUpdate, _VectorIndexConfigHNSWCreate, _VectorIndexConfigHNSWUpdate, + _VectorIndexConfigSPFreshCreate, + _VectorIndexConfigSPFreshUpdate, _VectorIndexConfigUpdate, ) from weaviate.collections.classes.config_vectorizers import ( @@ -126,6 +128,19 @@ def __hnsw( multivector=multivector, ) + @staticmethod + def __spfresh(*, quantizer: Optional[_QuantizerConfigCreate]) -> _VectorIndexConfigSPFreshCreate: + return _VectorIndexConfigSPFreshCreate( + distance_metric=None, + maxPostingSize=None, + minPostingSize=None, + replicas=None, + rngFactor=None, + searchProbe=None, + centroidsIndexType=None, + quantizer=quantizer, + ) + @staticmethod def __flat(*, quantizer: Optional[_QuantizerConfigCreate]) -> _VectorIndexConfigFlatCreate: return _VectorIndexConfigFlatCreate( @@ -1760,6 +1775,7 @@ def update( name: Optional[str] = None, vector_index_config: Union[ _VectorIndexConfigHNSWUpdate, + _VectorIndexConfigSPFreshUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigDynamicUpdate, ], diff --git a/weaviate/collections/config/async_.pyi b/weaviate/collections/config/async_.pyi index 9fcfefdb3..22e6c2021 100644 --- a/weaviate/collections/config/async_.pyi +++ b/weaviate/collections/config/async_.pyi @@ -21,6 +21,7 @@ from weaviate.collections.classes.config import ( _VectorConfigUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigHNSWUpdate, + _VectorIndexConfigSPFreshUpdate, ) from weaviate.collections.classes.config_vector_index import _VectorIndexConfigDynamicUpdate from weaviate.connect.v4 import ConnectionAsync @@ -45,13 +46,14 @@ class _ConfigCollectionAsync(_ConfigCollectionExecutor[ConnectionAsync]): multi_tenancy_config: Optional[_MultiTenancyConfigUpdate] = None, replication_config: Optional[_ReplicationConfigUpdate] = None, vector_index_config: Optional[ - Union[_VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate] + Union[_VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigSPFreshUpdate] ] = None, vectorizer_config: Optional[ Union[ _VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigDynamicUpdate, + _VectorIndexConfigSPFreshUpdate, List[_NamedVectorConfigUpdate], ] ] = None, diff --git a/weaviate/collections/config/executor.py b/weaviate/collections/config/executor.py index e5772b76a..6aa5de917 100644 --- a/weaviate/collections/config/executor.py +++ b/weaviate/collections/config/executor.py @@ -38,6 +38,7 @@ _VectorConfigUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigHNSWUpdate, + _VectorIndexConfigSPFreshUpdate, ) from weaviate.collections.classes.config_methods import ( _collection_config_from_json, @@ -134,6 +135,7 @@ def update( Union[ _VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, + _VectorIndexConfigSPFreshUpdate, ] ] = None, vectorizer_config: Optional[ @@ -141,6 +143,7 @@ def update( _VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigDynamicUpdate, + _VectorIndexConfigSPFreshUpdate, List[_NamedVectorConfigUpdate], ] ] = None, @@ -184,6 +187,7 @@ def update( _VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigDynamicUpdate, + _VectorIndexConfigSPFreshUpdate, ), ): _Warnings.vectorizer_config_in_config_update() diff --git a/weaviate/collections/config/sync.pyi b/weaviate/collections/config/sync.pyi index 89f37615e..29aeb9c94 100644 --- a/weaviate/collections/config/sync.pyi +++ b/weaviate/collections/config/sync.pyi @@ -21,6 +21,7 @@ from weaviate.collections.classes.config import ( _VectorConfigUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigHNSWUpdate, + _VectorIndexConfigSPFreshUpdate, ) from weaviate.collections.classes.config_vector_index import _VectorIndexConfigDynamicUpdate from weaviate.connect.v4 import ConnectionSync @@ -43,13 +44,14 @@ class _ConfigCollection(_ConfigCollectionExecutor[ConnectionSync]): multi_tenancy_config: Optional[_MultiTenancyConfigUpdate] = None, replication_config: Optional[_ReplicationConfigUpdate] = None, vector_index_config: Optional[ - Union[_VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate] + Union[_VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigSPFreshUpdate] ] = None, vectorizer_config: Optional[ Union[ _VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigDynamicUpdate, + _VectorIndexConfigSPFreshUpdate, List[_NamedVectorConfigUpdate], ] ] = None, diff --git a/weaviate/outputs/config.py b/weaviate/outputs/config.py index d6c8ed230..5f0e236f3 100644 --- a/weaviate/outputs/config.py +++ b/weaviate/outputs/config.py @@ -23,6 +23,7 @@ VectorDistances, VectorIndexConfigFlat, VectorIndexConfigHNSW, + VectorIndexConfigSPFresh, VectorIndexType, VectorizerConfig, Vectorizers, @@ -52,6 +53,7 @@ "ShardTypes", "VectorDistances", "VectorIndexConfigHNSW", + "VectorIndexConfigSPFresh", "VectorIndexConfigFlat", "VectorIndexType", "Vectorizers", From ffc98b3f09246f2fdacfd2a93496f6eb425cce77 Mon Sep 17 00:00:00 2001 From: Roberto Esposito Date: Fri, 17 Oct 2025 12:09:49 +0200 Subject: [PATCH 10/18] add enum for centroids index type in spfresh --- weaviate/classes/config.py | 2 ++ weaviate/collections/classes/config.py | 3 ++- weaviate/collections/classes/config_methods.py | 7 ++++++- .../collections/classes/config_vector_index.py | 16 ++++++++++++++-- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/weaviate/classes/config.py b/weaviate/classes/config.py index 651818de3..a214e6811 100644 --- a/weaviate/classes/config.py +++ b/weaviate/classes/config.py @@ -17,6 +17,7 @@ from weaviate.collections.classes.config_vector_index import ( MultiVectorAggregation, VectorFilterStrategy, + VectorCentroidsIndexType ) from weaviate.collections.classes.config_vectorizers import Multi2VecField, Vectorizers from weaviate.connect.integrations import Integrations @@ -41,4 +42,5 @@ "Vectorizers", "VectorDistances", "VectorFilterStrategy", + "VectorCentroidsIndexType", ] diff --git a/weaviate/collections/classes/config.py b/weaviate/collections/classes/config.py index 703b513a6..88b636ef4 100644 --- a/weaviate/collections/classes/config.py +++ b/weaviate/collections/classes/config.py @@ -35,6 +35,7 @@ PQEncoderDistribution, PQEncoderType, VectorFilterStrategy, + VectorCentroidsIndexType, _BQConfigUpdate, _PQConfigUpdate, _PQEncoderConfigUpdate, @@ -1895,7 +1896,7 @@ class _VectorIndexConfigSPFresh(_VectorIndexConfig): replicas: int rng_factor: int search_probe: int - centroids_index_type: str + centroids_index_type: VectorCentroidsIndexType @staticmethod def vector_index_type() -> str: diff --git a/weaviate/collections/classes/config_methods.py b/weaviate/collections/classes/config_methods.py index d5845e86a..ec5692883 100644 --- a/weaviate/collections/classes/config_methods.py +++ b/weaviate/collections/classes/config_methods.py @@ -12,6 +12,7 @@ VectorDistances, VectorFilterStrategy, VectorIndexType, + VectorCentroidsIndexType, Vectorizers, _BM25Config, _BQConfig, @@ -220,7 +221,11 @@ def __get_spfresh_config(config: Dict[str, Any]) -> _VectorIndexConfigSPFresh: replicas=config["replicas"], rng_factor=config["rngFactor"], search_probe=config["searchProbe"], - centroids_index_type=config["centroidsIndexType"], + centroids_index_type=( + VectorCentroidsIndexType(config["centroidsIndexType"]) + if "centroidsIndexType" in config + else VectorCentroidsIndexType.HNSW + ), quantizer=quantizer, ) diff --git a/weaviate/collections/classes/config_vector_index.py b/weaviate/collections/classes/config_vector_index.py index 87ffe7017..7d98e9cb4 100644 --- a/weaviate/collections/classes/config_vector_index.py +++ b/weaviate/collections/classes/config_vector_index.py @@ -44,6 +44,18 @@ class VectorIndexType(str, Enum): SPFRESH = "spfresh" +class VectorCentroidsIndexType(str, Enum): + """The available index type that can be used for centroids in SPFresh. + + Attributes: + HNSW: Hierarchical Navigable Small World (HNSW) index. + FLAT: flat index. + """ + + HNSW = "hnsw" + FLAT = "bruteforce" + + class _MultiVectorConfigCreateBase(_ConfigCreateModel): enabled: bool = Field(default=True) @@ -136,7 +148,7 @@ class _VectorIndexConfigSPFreshCreate(_VectorIndexConfigCreate): replicas: Optional[int] rngFactor: Optional[int] searchProbe: Optional[int] - centroidsIndexType: Optional[str] + centroidsIndexType: Optional[VectorCentroidsIndexType] @staticmethod def vector_index_type() -> VectorIndexType: @@ -599,7 +611,7 @@ def spfresh( replicas: Optional[int] = None, rng_factor: Optional[int] = None, search_probe: Optional[int] = None, - centroids_index_type: Optional[str] = None, + centroids_index_type: Optional[VectorCentroidsIndexType] = None, quantizer: Optional[_QuantizerConfigCreate] = None, ) -> _VectorIndexConfigSPFreshCreate: """Create a `_VectorIndexConfigSPFreshCreate` object to be used when defining the SPFresh vector index configuration of Weaviate. From 1059b43d10cd1d8ba8199ba748665257905b5269 Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez Date: Mon, 17 Nov 2025 16:58:59 +0100 Subject: [PATCH 11/18] Add missing init parameter for spfresh --- weaviate/collections/classes/config_methods.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/weaviate/collections/classes/config_methods.py b/weaviate/collections/classes/config_methods.py index ec5692883..6068bbde1 100644 --- a/weaviate/collections/classes/config_methods.py +++ b/weaviate/collections/classes/config_methods.py @@ -227,6 +227,7 @@ def __get_spfresh_config(config: Dict[str, Any]) -> _VectorIndexConfigSPFresh: else VectorCentroidsIndexType.HNSW ), quantizer=quantizer, + multi_vector=__get_multivector(config), ) def __get_flat_config(config: Dict[str, Any]) -> _VectorIndexConfigFlat: @@ -241,7 +242,7 @@ def __get_flat_config(config: Dict[str, Any]) -> _VectorIndexConfigFlat: def __get_vector_index_config( schema: Dict[str, Any], -) -> Union[_VectorIndexConfigHNSW, _VectorIndexConfigFlat, _VectorIndexConfigDynamic, None]: +) -> Union[_VectorIndexConfigHNSW, _VectorIndexConfigFlat, _VectorIndexConfigDynamic, _VectorIndexConfigSPFresh, None]: if "vectorIndexConfig" not in schema: return None if schema["vectorIndexType"] == "hnsw": From 2cdc5e8315a6bf0a38dc2ff8852f496e719359fa Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez Date: Mon, 17 Nov 2025 17:05:44 +0100 Subject: [PATCH 12/18] Fix spfresh params in config of the class --- weaviate/collections/classes/config.py | 1 - weaviate/collections/classes/config_vectors.py | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/weaviate/collections/classes/config.py b/weaviate/collections/classes/config.py index 88b636ef4..acd49ce8a 100644 --- a/weaviate/collections/classes/config.py +++ b/weaviate/collections/classes/config.py @@ -46,7 +46,6 @@ _VectorIndexConfigDynamicUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigHNSWUpdate, - _VectorIndexConfigSPFreshUpdate, _VectorIndexConfigUpdate, ) from weaviate.collections.classes.config_vector_index import ( diff --git a/weaviate/collections/classes/config_vectors.py b/weaviate/collections/classes/config_vectors.py index a2beae6bb..76fac4814 100644 --- a/weaviate/collections/classes/config_vectors.py +++ b/weaviate/collections/classes/config_vectors.py @@ -131,7 +131,6 @@ def __hnsw( @staticmethod def __spfresh(*, quantizer: Optional[_QuantizerConfigCreate]) -> _VectorIndexConfigSPFreshCreate: return _VectorIndexConfigSPFreshCreate( - distance_metric=None, maxPostingSize=None, minPostingSize=None, replicas=None, @@ -139,6 +138,8 @@ def __spfresh(*, quantizer: Optional[_QuantizerConfigCreate]) -> _VectorIndexCon searchProbe=None, centroidsIndexType=None, quantizer=quantizer, + multivector=None, + distance=None, ) @staticmethod From e8847a8ccb40caa5251f6a73e804ed5e1c49bdd1 Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez Date: Mon, 17 Nov 2025 17:47:36 +0100 Subject: [PATCH 13/18] Add missing multivector param for spfresh --- weaviate/collections/classes/config_vector_index.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/weaviate/collections/classes/config_vector_index.py b/weaviate/collections/classes/config_vector_index.py index 7d98e9cb4..836ff70d7 100644 --- a/weaviate/collections/classes/config_vector_index.py +++ b/weaviate/collections/classes/config_vector_index.py @@ -613,6 +613,7 @@ def spfresh( search_probe: Optional[int] = None, centroids_index_type: Optional[VectorCentroidsIndexType] = None, quantizer: Optional[_QuantizerConfigCreate] = None, + multi_vector: Optional[_MultiVectorConfigCreate] = None, ) -> _VectorIndexConfigSPFreshCreate: """Create a `_VectorIndexConfigSPFreshCreate` object to be used when defining the SPFresh vector index configuration of Weaviate. @@ -630,7 +631,7 @@ def spfresh( searchProbe=search_probe, centroidsIndexType=centroids_index_type, quantizer=quantizer, - multivector=None, + multivector=multi_vector, ) @staticmethod From e735a581d0d83667b41e06580c5df32348e19fe3 Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez Date: Tue, 18 Nov 2025 11:36:08 +0100 Subject: [PATCH 14/18] Fix multivector --- weaviate/collections/classes/config.py | 1 + weaviate/collections/classes/config_methods.py | 2 +- weaviate/collections/classes/config_vector_index.py | 1 + weaviate/collections/classes/config_vectors.py | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/weaviate/collections/classes/config.py b/weaviate/collections/classes/config.py index acd49ce8a..88b636ef4 100644 --- a/weaviate/collections/classes/config.py +++ b/weaviate/collections/classes/config.py @@ -46,6 +46,7 @@ _VectorIndexConfigDynamicUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigHNSWUpdate, + _VectorIndexConfigSPFreshUpdate, _VectorIndexConfigUpdate, ) from weaviate.collections.classes.config_vector_index import ( diff --git a/weaviate/collections/classes/config_methods.py b/weaviate/collections/classes/config_methods.py index 6068bbde1..b59967afa 100644 --- a/weaviate/collections/classes/config_methods.py +++ b/weaviate/collections/classes/config_methods.py @@ -227,7 +227,7 @@ def __get_spfresh_config(config: Dict[str, Any]) -> _VectorIndexConfigSPFresh: else VectorCentroidsIndexType.HNSW ), quantizer=quantizer, - multi_vector=__get_multivector(config), + multi_vector=None, ) def __get_flat_config(config: Dict[str, Any]) -> _VectorIndexConfigFlat: diff --git a/weaviate/collections/classes/config_vector_index.py b/weaviate/collections/classes/config_vector_index.py index 836ff70d7..e81e435af 100644 --- a/weaviate/collections/classes/config_vector_index.py +++ b/weaviate/collections/classes/config_vector_index.py @@ -614,6 +614,7 @@ def spfresh( centroids_index_type: Optional[VectorCentroidsIndexType] = None, quantizer: Optional[_QuantizerConfigCreate] = None, multi_vector: Optional[_MultiVectorConfigCreate] = None, + ) -> _VectorIndexConfigSPFreshCreate: """Create a `_VectorIndexConfigSPFreshCreate` object to be used when defining the SPFresh vector index configuration of Weaviate. diff --git a/weaviate/collections/classes/config_vectors.py b/weaviate/collections/classes/config_vectors.py index 76fac4814..e0d558fce 100644 --- a/weaviate/collections/classes/config_vectors.py +++ b/weaviate/collections/classes/config_vectors.py @@ -131,6 +131,7 @@ def __hnsw( @staticmethod def __spfresh(*, quantizer: Optional[_QuantizerConfigCreate]) -> _VectorIndexConfigSPFreshCreate: return _VectorIndexConfigSPFreshCreate( + distance_metric=None, maxPostingSize=None, minPostingSize=None, replicas=None, From 88c276ca1a841f653ca5b7039c21be117a8b8cc3 Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez Date: Mon, 24 Nov 2025 16:34:58 +0100 Subject: [PATCH 15/18] Fix update spfresh method --- weaviate/collections/classes/config.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/weaviate/collections/classes/config.py b/weaviate/collections/classes/config.py index 88b636ef4..77a1680b5 100644 --- a/weaviate/collections/classes/config.py +++ b/weaviate/collections/classes/config.py @@ -2642,6 +2642,29 @@ def dynamic( quantizer=quantizer, ) + @staticmethod + def spfresh( + max_posting_size: Optional[int] = None, + min_posting_size: Optional[int] = None, + rng_factor: Optional[int] = None, + search_probe: Optional[int] = None, + quantizer: Optional[_RQConfigUpdate] = None, + ) -> _VectorIndexConfigSPFreshUpdate: + """Create an `_VectorIndexConfigSPFreshUpdate` object to update the configuration of the SPFresh vector index. + + Use this method when defining the `vectorizer_config` argument in `collection.update()`. + + Args: + See [the docs](https://weaviate.io/developers/weaviate/configuration/indexes#configure-the-inverted-index) for a more detailed view! + """ # noqa: D417 (missing argument descriptions in the docstring) + return _VectorIndexConfigSPFreshUpdate( + maxPostingSize=max_posting_size, + minPostingSize=min_posting_size, + rngFactor=rng_factor, + searchProbe=search_probe, + quantizer=quantizer, + ) + class Reconfigure: """Use this factory class to generate the correct `xxxConfig` object for use when using the `collection.update()` method. From 6d6afeb637022a82540a7e6866fc01068ab5f7e9 Mon Sep 17 00:00:00 2001 From: Roberto Esposito Date: Fri, 28 Nov 2025 14:29:28 +0100 Subject: [PATCH 16/18] remove centroids index type --- weaviate/collections/classes/config.py | 2 -- weaviate/collections/classes/config_methods.py | 6 ------ .../collections/classes/config_vector_index.py | 15 --------------- weaviate/collections/classes/config_vectors.py | 1 - 4 files changed, 24 deletions(-) diff --git a/weaviate/collections/classes/config.py b/weaviate/collections/classes/config.py index 77a1680b5..98ee3ae49 100644 --- a/weaviate/collections/classes/config.py +++ b/weaviate/collections/classes/config.py @@ -35,7 +35,6 @@ PQEncoderDistribution, PQEncoderType, VectorFilterStrategy, - VectorCentroidsIndexType, _BQConfigUpdate, _PQConfigUpdate, _PQEncoderConfigUpdate, @@ -1896,7 +1895,6 @@ class _VectorIndexConfigSPFresh(_VectorIndexConfig): replicas: int rng_factor: int search_probe: int - centroids_index_type: VectorCentroidsIndexType @staticmethod def vector_index_type() -> str: diff --git a/weaviate/collections/classes/config_methods.py b/weaviate/collections/classes/config_methods.py index b59967afa..f8179192f 100644 --- a/weaviate/collections/classes/config_methods.py +++ b/weaviate/collections/classes/config_methods.py @@ -12,7 +12,6 @@ VectorDistances, VectorFilterStrategy, VectorIndexType, - VectorCentroidsIndexType, Vectorizers, _BM25Config, _BQConfig, @@ -221,11 +220,6 @@ def __get_spfresh_config(config: Dict[str, Any]) -> _VectorIndexConfigSPFresh: replicas=config["replicas"], rng_factor=config["rngFactor"], search_probe=config["searchProbe"], - centroids_index_type=( - VectorCentroidsIndexType(config["centroidsIndexType"]) - if "centroidsIndexType" in config - else VectorCentroidsIndexType.HNSW - ), quantizer=quantizer, multi_vector=None, ) diff --git a/weaviate/collections/classes/config_vector_index.py b/weaviate/collections/classes/config_vector_index.py index e81e435af..2ef6b8ad1 100644 --- a/weaviate/collections/classes/config_vector_index.py +++ b/weaviate/collections/classes/config_vector_index.py @@ -44,18 +44,6 @@ class VectorIndexType(str, Enum): SPFRESH = "spfresh" -class VectorCentroidsIndexType(str, Enum): - """The available index type that can be used for centroids in SPFresh. - - Attributes: - HNSW: Hierarchical Navigable Small World (HNSW) index. - FLAT: flat index. - """ - - HNSW = "hnsw" - FLAT = "bruteforce" - - class _MultiVectorConfigCreateBase(_ConfigCreateModel): enabled: bool = Field(default=True) @@ -148,7 +136,6 @@ class _VectorIndexConfigSPFreshCreate(_VectorIndexConfigCreate): replicas: Optional[int] rngFactor: Optional[int] searchProbe: Optional[int] - centroidsIndexType: Optional[VectorCentroidsIndexType] @staticmethod def vector_index_type() -> VectorIndexType: @@ -611,7 +598,6 @@ def spfresh( replicas: Optional[int] = None, rng_factor: Optional[int] = None, search_probe: Optional[int] = None, - centroids_index_type: Optional[VectorCentroidsIndexType] = None, quantizer: Optional[_QuantizerConfigCreate] = None, multi_vector: Optional[_MultiVectorConfigCreate] = None, @@ -630,7 +616,6 @@ def spfresh( replicas=replicas, rngFactor=rng_factor, searchProbe=search_probe, - centroidsIndexType=centroids_index_type, quantizer=quantizer, multivector=multi_vector, ) diff --git a/weaviate/collections/classes/config_vectors.py b/weaviate/collections/classes/config_vectors.py index e0d558fce..553405a94 100644 --- a/weaviate/collections/classes/config_vectors.py +++ b/weaviate/collections/classes/config_vectors.py @@ -137,7 +137,6 @@ def __spfresh(*, quantizer: Optional[_QuantizerConfigCreate]) -> _VectorIndexCon replicas=None, rngFactor=None, searchProbe=None, - centroidsIndexType=None, quantizer=quantizer, multivector=None, distance=None, From fb49f84a59db6a38f9d2c3af2a3de4dbbc9fb7ba Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez Date: Wed, 17 Dec 2025 09:57:29 +0100 Subject: [PATCH 17/18] Rename spfresh to hfresh --- weaviate/collections/classes/config.py | 20 ++++++++--------- .../collections/classes/config_methods.py | 12 +++++----- .../classes/config_named_vectors.py | 4 ++-- .../classes/config_vector_index.py | 22 +++++++++---------- .../collections/classes/config_vectors.py | 10 ++++----- weaviate/collections/config/async_.pyi | 6 ++--- weaviate/collections/config/executor.py | 8 +++---- weaviate/collections/config/sync.pyi | 6 ++--- weaviate/outputs/config.py | 4 ++-- 9 files changed, 46 insertions(+), 46 deletions(-) diff --git a/weaviate/collections/classes/config.py b/weaviate/collections/classes/config.py index 98ee3ae49..32e153edd 100644 --- a/weaviate/collections/classes/config.py +++ b/weaviate/collections/classes/config.py @@ -45,7 +45,7 @@ _VectorIndexConfigDynamicUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigHNSWUpdate, - _VectorIndexConfigSPFreshUpdate, + _VectorIndexConfigHFreshUpdate, _VectorIndexConfigUpdate, ) from weaviate.collections.classes.config_vector_index import ( @@ -1888,7 +1888,7 @@ def vector_index_type() -> str: VectorIndexConfigHNSW = _VectorIndexConfigHNSW @dataclass -class _VectorIndexConfigSPFresh(_VectorIndexConfig): +class _VectorIndexConfigHFresh(_VectorIndexConfig): distance_metric: VectorDistances max_posting_size: int min_posting_size: int @@ -1898,9 +1898,9 @@ class _VectorIndexConfigSPFresh(_VectorIndexConfig): @staticmethod def vector_index_type() -> str: - return VectorIndexType.SPFRESH.value + return VectorIndexType.HFRESH.value -VectorIndexConfigSPFresh = _VectorIndexConfigSPFresh +VectorIndexConfigHFresh = _VectorIndexConfigHFresh @dataclass class _VectorIndexConfigFlat(_VectorIndexConfig): @@ -1975,7 +1975,7 @@ def to_dict(self) -> Dict[str, Any]: class _NamedVectorConfig(_ConfigBase): vectorizer: _NamedVectorizerConfig vector_index_config: Union[ - VectorIndexConfigHNSW, VectorIndexConfigFlat, VectorIndexConfigDynamic, VectorIndexConfigSPFresh + VectorIndexConfigHNSW, VectorIndexConfigFlat, VectorIndexConfigDynamic, VectorIndexConfigHFresh ] def to_dict(self) -> Dict: @@ -2000,7 +2000,7 @@ class _CollectionConfig(_ConfigBase): reranker_config: Optional[RerankerConfig] sharding_config: Optional[ShardingConfig] vector_index_config: Union[ - VectorIndexConfigHNSW, VectorIndexConfigFlat, VectorIndexConfigDynamic, VectorIndexConfigSPFresh, None + VectorIndexConfigHNSW, VectorIndexConfigFlat, VectorIndexConfigDynamic, VectorIndexConfigHFresh, None ] vector_index_type: Optional[VectorIndexType] vectorizer_config: Optional[VectorizerConfig] @@ -2641,21 +2641,21 @@ def dynamic( ) @staticmethod - def spfresh( + def hfresh( max_posting_size: Optional[int] = None, min_posting_size: Optional[int] = None, rng_factor: Optional[int] = None, search_probe: Optional[int] = None, quantizer: Optional[_RQConfigUpdate] = None, - ) -> _VectorIndexConfigSPFreshUpdate: - """Create an `_VectorIndexConfigSPFreshUpdate` object to update the configuration of the SPFresh vector index. + ) -> _VectorIndexConfigHFreshUpdate: + """Create an `_VectorIndexConfigHFreshUpdate` object to update the configuration of the HFresh vector index. Use this method when defining the `vectorizer_config` argument in `collection.update()`. Args: See [the docs](https://weaviate.io/developers/weaviate/configuration/indexes#configure-the-inverted-index) for a more detailed view! """ # noqa: D417 (missing argument descriptions in the docstring) - return _VectorIndexConfigSPFreshUpdate( + return _VectorIndexConfigHFreshUpdate( maxPostingSize=max_posting_size, minPostingSize=min_posting_size, rngFactor=rng_factor, diff --git a/weaviate/collections/classes/config_methods.py b/weaviate/collections/classes/config_methods.py index f8179192f..238c9cf06 100644 --- a/weaviate/collections/classes/config_methods.py +++ b/weaviate/collections/classes/config_methods.py @@ -39,7 +39,7 @@ _VectorIndexConfigDynamic, _VectorIndexConfigFlat, _VectorIndexConfigHNSW, - _VectorIndexConfigSPFresh, + _VectorIndexConfigHFresh, _VectorizerConfig, ) @@ -211,9 +211,9 @@ def __get_hnsw_config(config: Dict[str, Any]) -> _VectorIndexConfigHNSW: multi_vector=__get_multivector(config), ) -def __get_spfresh_config(config: Dict[str, Any]) -> _VectorIndexConfigSPFresh: +def __get_hfresh_config(config: Dict[str, Any]) -> _VectorIndexConfigHFresh: quantizer = __get_quantizer_config(config) - return _VectorIndexConfigSPFresh( + return _VectorIndexConfigHFresh( distance_metric=VectorDistances(config.get("distance")), max_posting_size=config["maxPostingSize"], min_posting_size=config["minPostingSize"], @@ -236,7 +236,7 @@ def __get_flat_config(config: Dict[str, Any]) -> _VectorIndexConfigFlat: def __get_vector_index_config( schema: Dict[str, Any], -) -> Union[_VectorIndexConfigHNSW, _VectorIndexConfigFlat, _VectorIndexConfigDynamic, _VectorIndexConfigSPFresh, None]: +) -> Union[_VectorIndexConfigHNSW, _VectorIndexConfigFlat, _VectorIndexConfigDynamic, _VectorIndexConfigHFresh, None]: if "vectorIndexConfig" not in schema: return None if schema["vectorIndexType"] == "hnsw": @@ -250,8 +250,8 @@ def __get_vector_index_config( hnsw=__get_hnsw_config(schema["vectorIndexConfig"]["hnsw"]), flat=__get_flat_config(schema["vectorIndexConfig"]["flat"]), ) - elif schema["vectorIndexType"] == "spfresh": - return __get_spfresh_config(schema["vectorIndexConfig"]) + elif schema["vectorIndexType"] == "hfresh": + return __get_hfresh_config(schema["vectorIndexConfig"]) else: return None diff --git a/weaviate/collections/classes/config_named_vectors.py b/weaviate/collections/classes/config_named_vectors.py index 8cc86c484..963b39b6a 100644 --- a/weaviate/collections/classes/config_named_vectors.py +++ b/weaviate/collections/classes/config_named_vectors.py @@ -15,7 +15,7 @@ _VectorIndexConfigDynamicUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigHNSWUpdate, - _VectorIndexConfigSPFreshUpdate, + _VectorIndexConfigHFreshUpdate, _VectorIndexConfigUpdate, ) from weaviate.collections.classes.config_vectorizers import ( @@ -1339,7 +1339,7 @@ def update( *, vector_index_config: Union[ _VectorIndexConfigHNSWUpdate, - _VectorIndexConfigSPFreshUpdate, + _VectorIndexConfigHFreshUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigDynamicUpdate, ], diff --git a/weaviate/collections/classes/config_vector_index.py b/weaviate/collections/classes/config_vector_index.py index 2ef6b8ad1..60bdfb39e 100644 --- a/weaviate/collections/classes/config_vector_index.py +++ b/weaviate/collections/classes/config_vector_index.py @@ -35,13 +35,13 @@ class VectorIndexType(str, Enum): HNSW: Hierarchical Navigable Small World (HNSW) index. FLAT: Flat index. DYNAMIC: Dynamic index. - SPFRESH: SPFRESH index. + HFRESH: HFRESH index. """ HNSW = "hnsw" FLAT = "flat" DYNAMIC = "dynamic" - SPFRESH = "spfresh" + HFRESH = "hfresh" class _MultiVectorConfigCreateBase(_ConfigCreateModel): @@ -130,7 +130,7 @@ def vector_index_type() -> VectorIndexType: return VectorIndexType.HNSW -class _VectorIndexConfigSPFreshCreate(_VectorIndexConfigCreate): +class _VectorIndexConfigHFreshCreate(_VectorIndexConfigCreate): maxPostingSize: Optional[int] minPostingSize: Optional[int] replicas: Optional[int] @@ -139,7 +139,7 @@ class _VectorIndexConfigSPFreshCreate(_VectorIndexConfigCreate): @staticmethod def vector_index_type() -> VectorIndexType: - return VectorIndexType.SPFRESH + return VectorIndexType.HFRESH class _VectorIndexConfigFlatCreate(_VectorIndexConfigCreate): @@ -164,7 +164,7 @@ def vector_index_type() -> VectorIndexType: return VectorIndexType.HNSW -class _VectorIndexConfigSPFreshUpdate(_VectorIndexConfigUpdate): +class _VectorIndexConfigHFreshUpdate(_VectorIndexConfigUpdate): maxPostingSize: Optional[int] minPostingSize: Optional[int] rngFactor: Optional[int] @@ -172,7 +172,7 @@ class _VectorIndexConfigSPFreshUpdate(_VectorIndexConfigUpdate): @staticmethod def vector_index_type() -> VectorIndexType: - return VectorIndexType.SPFRESH + return VectorIndexType.HFRESH class _VectorIndexConfigFlatUpdate(_VectorIndexConfigUpdate): @@ -591,7 +591,7 @@ def hnsw( ) @staticmethod - def spfresh( + def hfresh( distance_metric: Optional[VectorDistances] = None, max_posting_size: Optional[int] = None, min_posting_size: Optional[int] = None, @@ -601,15 +601,15 @@ def spfresh( quantizer: Optional[_QuantizerConfigCreate] = None, multi_vector: Optional[_MultiVectorConfigCreate] = None, - ) -> _VectorIndexConfigSPFreshCreate: - """Create a `_VectorIndexConfigSPFreshCreate` object to be used when defining the SPFresh vector index configuration of Weaviate. + ) -> _VectorIndexConfigHFreshCreate: + """Create a `_VectorIndexConfigHFreshCreate` object to be used when defining the HFresh vector index configuration of Weaviate. Use this method when defining the `vector_index_config` argument in `collections.create()`. Args: - See [the docs](https://weaviate.io/developers/weaviate/configuration/indexes#how-to-configure-spfresh) for a more detailed view! + See [the docs](https://weaviate.io/developers/weaviate/configuration/indexes#how-to-configure-hfresh) for a more detailed view! """ - return _VectorIndexConfigSPFreshCreate( + return _VectorIndexConfigHFreshCreate( distance=distance_metric, maxPostingSize=max_posting_size, minPostingSize=min_posting_size, diff --git a/weaviate/collections/classes/config_vectors.py b/weaviate/collections/classes/config_vectors.py index 553405a94..d004c0372 100644 --- a/weaviate/collections/classes/config_vectors.py +++ b/weaviate/collections/classes/config_vectors.py @@ -20,8 +20,8 @@ _VectorIndexConfigFlatUpdate, _VectorIndexConfigHNSWCreate, _VectorIndexConfigHNSWUpdate, - _VectorIndexConfigSPFreshCreate, - _VectorIndexConfigSPFreshUpdate, + _VectorIndexConfigHFreshCreate, + _VectorIndexConfigHFreshUpdate, _VectorIndexConfigUpdate, ) from weaviate.collections.classes.config_vectorizers import ( @@ -129,8 +129,8 @@ def __hnsw( ) @staticmethod - def __spfresh(*, quantizer: Optional[_QuantizerConfigCreate]) -> _VectorIndexConfigSPFreshCreate: - return _VectorIndexConfigSPFreshCreate( + def __hfresh(*, quantizer: Optional[_QuantizerConfigCreate]) -> _VectorIndexConfigHFreshCreate: + return _VectorIndexConfigHFreshCreate( distance_metric=None, maxPostingSize=None, minPostingSize=None, @@ -1776,7 +1776,7 @@ def update( name: Optional[str] = None, vector_index_config: Union[ _VectorIndexConfigHNSWUpdate, - _VectorIndexConfigSPFreshUpdate, + _VectorIndexConfigHFreshUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigDynamicUpdate, ], diff --git a/weaviate/collections/config/async_.pyi b/weaviate/collections/config/async_.pyi index 22e6c2021..1997eef2a 100644 --- a/weaviate/collections/config/async_.pyi +++ b/weaviate/collections/config/async_.pyi @@ -21,7 +21,7 @@ from weaviate.collections.classes.config import ( _VectorConfigUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigHNSWUpdate, - _VectorIndexConfigSPFreshUpdate, + _VectorIndexConfigHFreshUpdate, ) from weaviate.collections.classes.config_vector_index import _VectorIndexConfigDynamicUpdate from weaviate.connect.v4 import ConnectionAsync @@ -46,14 +46,14 @@ class _ConfigCollectionAsync(_ConfigCollectionExecutor[ConnectionAsync]): multi_tenancy_config: Optional[_MultiTenancyConfigUpdate] = None, replication_config: Optional[_ReplicationConfigUpdate] = None, vector_index_config: Optional[ - Union[_VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigSPFreshUpdate] + Union[_VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigHFreshUpdate] ] = None, vectorizer_config: Optional[ Union[ _VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigDynamicUpdate, - _VectorIndexConfigSPFreshUpdate, + _VectorIndexConfigHFreshUpdate, List[_NamedVectorConfigUpdate], ] ] = None, diff --git a/weaviate/collections/config/executor.py b/weaviate/collections/config/executor.py index 6aa5de917..80534531a 100644 --- a/weaviate/collections/config/executor.py +++ b/weaviate/collections/config/executor.py @@ -38,7 +38,7 @@ _VectorConfigUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigHNSWUpdate, - _VectorIndexConfigSPFreshUpdate, + _VectorIndexConfigHFreshUpdate, ) from weaviate.collections.classes.config_methods import ( _collection_config_from_json, @@ -135,7 +135,7 @@ def update( Union[ _VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, - _VectorIndexConfigSPFreshUpdate, + _VectorIndexConfigHFreshUpdate, ] ] = None, vectorizer_config: Optional[ @@ -143,7 +143,7 @@ def update( _VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigDynamicUpdate, - _VectorIndexConfigSPFreshUpdate, + _VectorIndexConfigHFreshUpdate, List[_NamedVectorConfigUpdate], ] ] = None, @@ -187,7 +187,7 @@ def update( _VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigDynamicUpdate, - _VectorIndexConfigSPFreshUpdate, + _VectorIndexConfigHFreshUpdate, ), ): _Warnings.vectorizer_config_in_config_update() diff --git a/weaviate/collections/config/sync.pyi b/weaviate/collections/config/sync.pyi index 29aeb9c94..3c9dd9dd9 100644 --- a/weaviate/collections/config/sync.pyi +++ b/weaviate/collections/config/sync.pyi @@ -21,7 +21,7 @@ from weaviate.collections.classes.config import ( _VectorConfigUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigHNSWUpdate, - _VectorIndexConfigSPFreshUpdate, + _VectorIndexConfigHFreshUpdate, ) from weaviate.collections.classes.config_vector_index import _VectorIndexConfigDynamicUpdate from weaviate.connect.v4 import ConnectionSync @@ -44,14 +44,14 @@ class _ConfigCollection(_ConfigCollectionExecutor[ConnectionSync]): multi_tenancy_config: Optional[_MultiTenancyConfigUpdate] = None, replication_config: Optional[_ReplicationConfigUpdate] = None, vector_index_config: Optional[ - Union[_VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigSPFreshUpdate] + Union[_VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigHFreshUpdate] ] = None, vectorizer_config: Optional[ Union[ _VectorIndexConfigHNSWUpdate, _VectorIndexConfigFlatUpdate, _VectorIndexConfigDynamicUpdate, - _VectorIndexConfigSPFreshUpdate, + _VectorIndexConfigHFreshUpdate, List[_NamedVectorConfigUpdate], ] ] = None, diff --git a/weaviate/outputs/config.py b/weaviate/outputs/config.py index 5f0e236f3..d6c3b4965 100644 --- a/weaviate/outputs/config.py +++ b/weaviate/outputs/config.py @@ -23,7 +23,7 @@ VectorDistances, VectorIndexConfigFlat, VectorIndexConfigHNSW, - VectorIndexConfigSPFresh, + VectorIndexConfigHFresh, VectorIndexType, VectorizerConfig, Vectorizers, @@ -53,7 +53,7 @@ "ShardTypes", "VectorDistances", "VectorIndexConfigHNSW", - "VectorIndexConfigSPFresh", + "VectorIndexConfigHFresh", "VectorIndexConfigFlat", "VectorIndexType", "Vectorizers", From f46fc4a1f75b523a4babf250dfbb023919e9a699 Mon Sep 17 00:00:00 2001 From: Roberto Esposito Date: Wed, 17 Dec 2025 16:22:34 +0100 Subject: [PATCH 18/18] remove centroids index type --- weaviate/classes/config.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/weaviate/classes/config.py b/weaviate/classes/config.py index a214e6811..651818de3 100644 --- a/weaviate/classes/config.py +++ b/weaviate/classes/config.py @@ -17,7 +17,6 @@ from weaviate.collections.classes.config_vector_index import ( MultiVectorAggregation, VectorFilterStrategy, - VectorCentroidsIndexType ) from weaviate.collections.classes.config_vectorizers import Multi2VecField, Vectorizers from weaviate.connect.integrations import Integrations @@ -42,5 +41,4 @@ "Vectorizers", "VectorDistances", "VectorFilterStrategy", - "VectorCentroidsIndexType", ]