@@ -35,9 +35,11 @@ def to_dict(self) -> dict:
3535
3636class DorisCaseConfig (BaseModel , DBCaseConfig ):
3737 metric_type : MetricType | None = None
38- # Optional explicit HNSW params for convenience
38+ # Optional explicit HNSW/IVF params for convenience
39+ index_type : str | None = None
3940 m : int | None = None
4041 ef_construction : int | None = None
42+ nlist : int | None = None
4143 # Arbitrary index properties and session variables
4244 index_properties : dict [str , str ] | None = None
4345 session_vars : dict [str , str ] | None = None
@@ -59,15 +61,30 @@ def get_metric_fn(self) -> str:
5961
6062 def index_param (self ) -> dict :
6163 # Use exact metric function name for index creation by removing '_approximate' suffix
62- metric_fn = self .get_metric_fn ()
63- if metric_fn .endswith ("_approximate" ):
64- metric_fn = metric_fn [: - len ("_approximate" )]
65- props = {"metric_fn" : metric_fn }
64+ metric_type = self .get_metric_fn ()
65+ if metric_type .endswith ("_approximate" ):
66+ metric_type = metric_type [: - len ("_approximate" )]
67+ props = {"metric_type" : metric_type }
68+
69+ if self .index_type is not None :
70+ props .setdefault ("index_type" , self .index_type )
71+ else :
72+ props .setdefault ("index_type" , "hnsw" )
73+
6674 # Merge optional HNSW params
67- if self .m is not None :
68- props .setdefault ("max_degree" , str (self .m ))
69- if self .ef_construction is not None :
70- props .setdefault ("ef_construction" , str (self .ef_construction ))
75+ props ["index_type" ] = str .lower (props ["index_type" ])
76+ if props ["index_type" ] == "hnsw" :
77+ if self .m is not None :
78+ props .setdefault ("max_degree" , str (self .m ))
79+ if self .ef_construction is not None :
80+ props .setdefault ("ef_construction" , str (self .ef_construction ))
81+ elif props ["index_type" ] == "ivf" :
82+ if self .nlist is not None :
83+ props .setdefault ("nlist" , str (self .nlist ))
84+ else :
85+ msg = f"Unsupported index type: { props ['index_type' ]} "
86+ raise ValueError (msg )
87+
7188 # Merge user provided index_properties
7289 if self .index_properties :
7390 props .update (self .index_properties )
0 commit comments