diff --git a/redis/commands/search/query.py b/redis/commands/search/query.py index 5071cfabf2..362dd6c72a 100644 --- a/redis/commands/search/query.py +++ b/redis/commands/search/query.py @@ -194,7 +194,7 @@ def _get_args_tags(self): args += self._ids if self._slop >= 0: args += ["SLOP", self._slop] - if self._timeout: + if self._timeout is not None: args += ["TIMEOUT", self._timeout] if self._in_order: args.append("INORDER") diff --git a/tests/test_search.py b/tests/test_search.py index f3f9619d92..7612332470 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -2264,6 +2264,8 @@ def test_withsuffixtrie(client: redis.Redis): def test_query_timeout(r: redis.Redis): q1 = Query("foo").timeout(5000) assert q1.get_args() == ["foo", "TIMEOUT", 5000, "LIMIT", 0, 10] + q1 = Query("foo").timeout(0) + assert q1.get_args() == ["foo", "TIMEOUT", 0, "LIMIT", 0, 10] q2 = Query("foo").timeout("not_a_number") with pytest.raises(redis.ResponseError): r.ft().search(q2)