From 79a77cfa7f84c4208dfb9115b896a9b026d9aadd Mon Sep 17 00:00:00 2001 From: Arya Rizky Date: Thu, 14 May 2026 21:13:59 +0700 Subject: [PATCH] fix: add cluster hash-tag validation to drop_keys Add the same RedisCluster hash-tag validation to SearchIndex.drop_keys that drop_documents already has. This prevents cross-slot errors when calling drop_keys with keys that hash to different slots on a clustered Redis deployment. The check raises ValueError when the Redis client is a RedisCluster instance and the provided keys don't share a hash tag, consistent with drop_documents behavior. Closes #601 --- redisvl/index/index.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/redisvl/index/index.py b/redisvl/index/index.py index 4d7a871b..6b6fefc7 100644 --- a/redisvl/index/index.py +++ b/redisvl/index/index.py @@ -833,6 +833,13 @@ def drop_keys(self, keys: str | list[str]) -> int: int: Count of records deleted from Redis. """ if isinstance(keys, list): + # Check for cluster compatibility + if isinstance( + self._redis_client, RedisCluster + ) and not _keys_share_hash_tag(keys): + raise ValueError( + "All keys must share a hash tag when using Redis Cluster." + ) return self._redis_client.delete(*keys) # type: ignore else: return self._redis_client.delete(keys) # type: ignore