1919from redisvl .redis .constants import (
2020 REDIS_URL_ENV_VAR ,
2121 SVS_MIN_REDIS_VERSION ,
22- SVS_REQUIRED_MODULES ,
22+ SVS_MIN_SEARCH_VERSION ,
2323)
2424from redisvl .redis .utils import convert_bytes , is_cluster_url
2525from redisvl .types import AsyncRedisClient , RedisClient , SyncRedisClient
@@ -72,16 +72,16 @@ def _strip_cluster_from_url_and_kwargs(
7272 return cleaned_url , cleaned_kwargs
7373
7474
75- def compare_versions (version1 : str , version2 : str ):
75+ def is_version_gte (version1 : str , version2 : str ) -> bool :
7676 """
77- Compare two Redis version strings numerically .
77+ Check if version1 >= version2 .
7878
7979 Parameters:
80- version1 (str): The first version string (e.g., "7.2.4").
81- version2 (str): The second version string (e.g., "6.2.1").
80+ version1 (str): The first version string (e.g., "7.2.4").
81+ version2 (str): The second version string (e.g., "6.2.1").
8282
8383 Returns:
84- int: -1 if version1 < version2, 0 if version1 == version2, 1 if version1 > version2 .
84+ bool: True if version1 >= version2, False otherwise .
8585 """
8686 v1_parts = list (map (int , version1 .split ("." )))
8787 v2_parts = list (map (int , version2 .split ("." )))
@@ -106,44 +106,14 @@ def unpack_redis_modules(module_list: List[Dict[str, Any]]) -> Dict[str, Any]:
106106 return {module ["name" ]: module ["ver" ] for module in module_list }
107107
108108
109- @dataclass
110- class VectorSupport :
111- """Redis server capabilities for vector operations."""
112-
113- redis_version : str
114- search_version : int
115- searchlight_version : int
116- svs_vamana_supported : bool
117-
118- @property
119- def search_version_str (self ) -> str :
120- """Format search module version as string."""
121- return format_module_version (self .search_version )
122-
123- @property
124- def searchlight_version_str (self ) -> str :
125- """Format searchlight module version as string."""
126- return format_module_version (self .searchlight_version )
127-
128-
129- def format_module_version (version : int ) -> str :
130- """Format module version from integer (20810) to string (2.8.10)."""
131- if version == 0 :
132- return "not installed"
133- major = version // 10000
134- minor = (version % 10000 ) // 100
135- patch = version % 100
136- return f"{ major } .{ minor } .{ patch } "
137-
138-
139- def check_vector_capabilities (client : SyncRedisClient ) -> VectorSupport :
140- """Check Redis server capabilities for vector features.
109+ def supports_svs (client : SyncRedisClient ) -> bool :
110+ """Check if Redis server supports SVS-VAMANA.
141111
142112 Args:
143113 client: Sync Redis client instance
144114
145115 Returns:
146- VectorSupport with version info and supported features
116+ True if SVS-VAMANA is supported, False otherwise
147117 """
148118 info = client .info ("server" ) # type: ignore[union-attr]
149119 redis_version = info .get ("redis_version" , "0.0.0" ) # type: ignore[union-attr]
@@ -153,25 +123,26 @@ def check_vector_capabilities(client: SyncRedisClient) -> VectorSupport:
153123 searchlight_ver = modules .get ("searchlight" , 0 )
154124
155125 # Check if SVS-VAMANA requirements are met
156- redis_ok = compare_versions (redis_version , SVS_MIN_REDIS_VERSION )
157- modules_ok = search_ver >= 20810 or searchlight_ver >= 20810
158-
159- return VectorSupport (
160- redis_version = redis_version ,
161- search_version = search_ver ,
162- searchlight_version = searchlight_ver ,
163- svs_vamana_supported = redis_ok and modules_ok ,
126+ redis_ok = is_version_gte (redis_version , SVS_MIN_REDIS_VERSION )
127+
128+ # Check either search or searchlight module (only one is typically installed)
129+ # RediSearch is the open-source module, SearchLight is the enterprise version
130+ modules_ok = (
131+ search_ver >= SVS_MIN_SEARCH_VERSION
132+ or searchlight_ver >= SVS_MIN_SEARCH_VERSION
164133 )
165134
135+ return redis_ok and modules_ok
136+
166137
167- async def check_vector_capabilities_async (client : AsyncRedisClient ) -> VectorSupport :
168- """Async version of check_vector_capabilities .
138+ async def supports_svs_async (client : AsyncRedisClient ) -> bool :
139+ """Async version of _supports_svs .
169140
170141 Args:
171142 client: Async Redis client instance
172143
173144 Returns:
174- VectorSupport with version info and supported features
145+ True if SVS-VAMANA is supported, False otherwise
175146 """
176147 info = await client .info ("server" ) # type: ignore[union-attr]
177148 redis_version = info .get ("redis_version" , "0.0.0" ) # type: ignore[union-attr]
@@ -181,16 +152,17 @@ async def check_vector_capabilities_async(client: AsyncRedisClient) -> VectorSup
181152 searchlight_ver = modules .get ("searchlight" , 0 )
182153
183154 # Check if SVS-VAMANA requirements are met
184- redis_ok = compare_versions (redis_version , SVS_MIN_REDIS_VERSION )
185- modules_ok = search_ver >= 20810 or searchlight_ver >= 20810
186-
187- return VectorSupport (
188- redis_version = redis_version ,
189- search_version = search_ver ,
190- searchlight_version = searchlight_ver ,
191- svs_vamana_supported = redis_ok and modules_ok ,
155+ redis_ok = is_version_gte (redis_version , SVS_MIN_REDIS_VERSION )
156+
157+ # Check either search or searchlight module (only one is typically installed)
158+ # RediSearch is the open-source module, SearchLight is the enterprise version
159+ modules_ok = (
160+ search_ver >= SVS_MIN_SEARCH_VERSION
161+ or searchlight_ver >= SVS_MIN_SEARCH_VERSION
192162 )
193163
164+ return redis_ok and modules_ok
165+
194166
195167def get_address_from_env () -> str :
196168 """Get Redis URL from environment variable."""
0 commit comments