Skip to content

Commit 6a4c16f

Browse files
Adds testcase for RECUCE and COMPRESSION in ft.createindex
Signed-off-by: Elena Kolevska <[email protected]>
1 parent 38fda1f commit 6a4c16f

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

tests/test_search.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3802,3 +3802,51 @@ def test_svs_vamana_vector_search_with_parameters(client):
38023802
else:
38033803
assert res["total_results"] == 3
38043804
assert "doc0" == res["results"][0]["id"]
3805+
3806+
@pytest.mark.redismod
3807+
@skip_ifmodversion_lt("2.4.3", "search")
3808+
@skip_if_server_version_lt("8.1.224")
3809+
def test_svs_vamana_vector_search_with_parameters_leanvec(client):
3810+
client.ft().create_index(
3811+
(
3812+
VectorField(
3813+
"v",
3814+
"SVS-VAMANA",
3815+
{
3816+
"TYPE": "FLOAT32",
3817+
"DIM": 8,
3818+
"DISTANCE_METRIC": "L2",
3819+
"COMPRESSION": "LVQ8", # LeanVec compression required for REDUCE
3820+
"CONSTRUCTION_WINDOW_SIZE": 200,
3821+
"GRAPH_MAX_DEGREE": 32,
3822+
"SEARCH_WINDOW_SIZE": 15,
3823+
"EPSILON": 0.01,
3824+
"TRAINING_THRESHOLD": 1024,
3825+
"REDUCE": 4, # Half of DIM (8/2 = 4)
3826+
},
3827+
),
3828+
)
3829+
)
3830+
3831+
# Create test vectors (8-dimensional to match DIM)
3832+
vectors = [
3833+
[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0],
3834+
[2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0],
3835+
[3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0],
3836+
[4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0],
3837+
[5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0],
3838+
]
3839+
3840+
for i, vec in enumerate(vectors):
3841+
client.hset(f"doc{i}", "v", np.array(vec, dtype=np.float32).tobytes())
3842+
3843+
query = Query("*=>[KNN 3 @v $vec as score]").no_content()
3844+
query_params = {"vec": np.array(vectors[0], dtype=np.float32).tobytes()}
3845+
3846+
res = client.ft().search(query, query_params=query_params)
3847+
if is_resp2_connection(client):
3848+
assert res.total == 3
3849+
assert "doc0" == res.docs[0].id
3850+
else:
3851+
assert res["total_results"] == 3
3852+
assert "doc0" == res["results"][0]["id"]

0 commit comments

Comments
 (0)