@@ -157,17 +157,42 @@ def _create_table(self):
157157 {"id" : 1 , "embedding" : [0.0 ] * self .dim }
158158 ])
159159
160- # Prepare index options
160+ # Prepare index options (attach custom HNSW properties if provided)
161161 index_options = None
162162 if not getattr (self .case_config , "no_index" , False ):
163163 index_param = self .case_config .index_param ()
164164 metric_type = index_param .get ("metric_fn" , "l2_distance" )
165-
166165 index_options = IndexOptions (
167166 index_type = "hnsw" ,
168167 metric_type = metric_type ,
169- dim = self .dim
168+ dim = self .dim ,
170169 )
170+ # Anything beyond metric_fn are treated as index properties (e.g. max_degree, ef_construction, user props)
171+ extra_props = {k : v for k , v in index_param .items () if k != "metric_fn" }
172+ # Try to set as attributes first; fall back to a generic properties dict
173+ if extra_props :
174+ applied , stored = {}, {}
175+ for k , v in extra_props .items ():
176+ attr_name = k
177+ if hasattr (index_options , attr_name ):
178+ try :
179+ setattr (index_options , attr_name , v )
180+ applied [k ] = v
181+ except Exception : # noqa: BLE001
182+ stored [k ] = v
183+ else :
184+ stored [k ] = v
185+ if stored :
186+ # Keep a dynamic container so downstream SDK logic can inspect
187+ setattr (index_options , "properties" , {** getattr (index_options , "properties" , {}), ** stored })
188+ log .info (
189+ "Index options prepared: metric=%s applied_props=%s stored_props=%s" ,
190+ metric_type ,
191+ applied ,
192+ stored ,
193+ )
194+ else :
195+ log .info ("Index options prepared: metric=%s (no extra properties)" , metric_type )
171196 log .info ("Creating table %s with index %s" , self .table_name , index_param )
172197 else :
173198 log .info ("Creating table %s without ANN index" , self .table_name )
@@ -188,6 +213,14 @@ def _create_table(self):
188213 self .table .index_options .metric_type = "inner_product"
189214 else :
190215 self .table .index_options .metric_type = "l2_distance"
216+ # Re-apply dynamic properties to runtime index object if we stored them
217+ if index_options and hasattr (index_options , "properties" ) and isinstance (index_options .properties , dict ):
218+ for k , v in index_options .properties .items ():
219+ if hasattr (self .table .index_options , k ):
220+ try :
221+ setattr (self .table .index_options , k , v )
222+ except Exception : # noqa: BLE001
223+ log .debug ("Skip setting index_options.%s at runtime" , k )
191224 except Exception :
192225 pass
193226
0 commit comments