@@ -139,6 +139,8 @@ struct VectorDef {
139
139
metric : spec:: VectorSimilarityMetric ,
140
140
#[ serde( default , skip_serializing_if = "Option::is_none" ) ]
141
141
multi_vector_comparator : Option < String > ,
142
+ #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
143
+ method : Option < spec:: VectorIndexMethod > ,
142
144
}
143
145
#[ derive( Debug , Clone , Serialize , Deserialize ) ]
144
146
struct SetupState {
@@ -221,6 +223,26 @@ impl SetupChange {
221
223
vector_def. vector_size as u64 ,
222
224
embedding_metric_to_qdrant ( vector_def. metric ) ?,
223
225
) ;
226
+ if let Some ( method) = & vector_def. method {
227
+ match method {
228
+ spec:: VectorIndexMethod :: Hnsw { m, ef_construction } => {
229
+ if let Some ( m_val) = m {
230
+ params = params. hnsw_m ( * m_val as u64 ) ;
231
+ }
232
+ if let Some ( ef_val) = ef_construction {
233
+ params = params. hnsw_ef_construct ( * ef_val as u64 ) ;
234
+ }
235
+ }
236
+ spec:: VectorIndexMethod :: IvfFlat { nlist } => {
237
+ if let Some ( nlist_val) = nlist {
238
+ params = params. ivf_flat_nlist ( * nlist_val as u64 ) ;
239
+ }
240
+ }
241
+ _ => {
242
+ api_bail ! ( "Unsupported vector index method for Qdrant" ) ;
243
+ }
244
+ }
245
+ }
224
246
if let Some ( multi_vector_comparator) = & vector_def. multi_vector_comparator {
225
247
params = params. multivector_config ( MultiVectorConfigBuilder :: new (
226
248
MultiVectorComparator :: from_str_name ( multi_vector_comparator)
@@ -422,8 +444,23 @@ impl TargetFactoryBase for Factory {
422
444
} else {
423
445
api_bail ! ( "Field `{}` specified more than once in vector index definition" , vector_index. field_name) ;
424
446
}
425
- if vector_index. method . is_some ( ) {
426
- api_bail ! ( "Vector index method is not configurable for Qdrant yet" ) ;
447
+
448
+ let vector_def_entry = vector_def. get_mut ( & vector_index. field_name )
449
+ . expect ( "VectorDef must exist here" ) ;
450
+
451
+ vector_def_entry. vector_size = vector_index. vector_size ;
452
+ vector_def_entry. metric = vector_index. metric . clone ( ) ;
453
+
454
+ if let Some ( method) = & vector_index. method {
455
+ match method {
456
+ spec:: VectorIndexMethod :: Hnsw { .. } |
457
+ spec:: VectorIndexMethod :: IvfFlat { .. } => {
458
+ vector_def_entry. method = Some ( method. clone ( ) ) ;
459
+ }
460
+ _ => {
461
+ api_bail ! ( "Vector index method is not supported for Qdrant" ) ;
462
+ }
463
+ }
427
464
}
428
465
}
429
466
None => {
0 commit comments