@@ -36,7 +36,12 @@ def test_vector_store_init_index():
3636    index_name  =  str (uuid .uuid4 ())
3737
3838    index_config  =  HNSWConfig (
39-         name = index_name , distance_strategy = DistanceStrategy .COSINE , vector_size = 128 
39+         name = index_name ,
40+         distance_strategy = DistanceStrategy .COSINE ,
41+         vector_size = 128 ,
42+         m = 1 ,
43+         ef_construction = 2 ,
44+         ef_runtime = 3 ,
4045    )
4146
4247    assert  not  check_index_exists (client , index_name , index_config )
@@ -134,8 +139,7 @@ def test_vector_store_add_texts(texts, metadatas, ids):
134139
135140    # Verify no extra keys are present 
136141    all_keys  =  [key .decode ("utf-8" ) for  key  in  client .keys (f"{ index_name }  )]
137-     # Currently RedisQuery stores the index schema as a key using the index_name 
138-     assert  len (all_keys ) ==  len (returned_ids ) +  1 , "Found unexpected keys in Redis" 
142+     assert  len (all_keys ) ==  len (returned_ids ), "Found unexpected keys in Redis" 
139143
140144    # Clena up 
141145    RedisVectorStore .drop_index (client = client , index_name = index_name )
@@ -233,7 +237,7 @@ def test_vector_store_range_query(distance_strategy, distance_threshold):
233237
234238
235239def  check_index_exists (
236-     client : redis .Redis , index_name : str , index_config : VectorIndexConfig 
240+     client : redis .Redis , index_name : str , index_config : HNSWConfig 
237241) ->  bool :
238242    try :
239243        index_info  =  client .ft (index_name ).info ()
@@ -243,6 +247,18 @@ def check_index_exists(
243247    return  (
244248        index_info ["index_name" ] ==  index_name 
245249        and  index_info ["index_definition" ][1 ] ==  b"HASH" 
250+         and  index_info ["index_definition" ][3 ][0 ].decode ("utf-8" ) ==  index_config .name 
251+         and  index_info ["attributes" ][0 ][1 ].decode ("utf-8" ) ==  index_config .field_name 
252+         and  index_info ["attributes" ][0 ][3 ].decode ("utf-8" ) ==  index_config .field_name 
253+         and  index_info ["attributes" ][0 ][5 ] ==  b"VECTOR" 
254+         and  index_info ["attributes" ][0 ][7 ][3 ] ==  index_config .vector_size 
255+         and  index_info ["attributes" ][0 ][7 ][5 ].decode ("utf-8" )
256+         ==  index_config .distance_metric 
257+         and  index_info ["attributes" ][0 ][7 ][7 ].decode ("utf-8" ) ==  index_config .data_type 
258+         and  index_info ["attributes" ][0 ][7 ][9 ][1 ] ==  b"HNSW" 
259+         and  index_info ["attributes" ][0 ][7 ][9 ][3 ] ==  index_config .m 
260+         and  index_info ["attributes" ][0 ][7 ][9 ][5 ] ==  index_config .ef_construction 
261+         and  index_info ["attributes" ][0 ][7 ][9 ][7 ] ==  index_config .ef_runtime 
246262    )
247263
248264
0 commit comments