@@ -3,20 +3,26 @@ use crate::args::Args;
33use crate :: crasher_error:: CrasherError ;
44use crate :: crasher_error:: CrasherError :: Cancelled ;
55use crate :: generators:: {
6- MANDATORY_PAYLOAD_BOOL_KEY , MANDATORY_PAYLOAD_TIMESTAMP_KEY , TestNamedVectors ,
6+ BOOL_PAYLOAD_KEY , DATETIME_PAYLOAD_KEY , FLOAT_PAYLOAD_KEY , GEO_PAYLOAD_KEY ,
7+ INTEGER_PAYLOAD_KEY , KEYWORD_PAYLOAD_KEY , MANDATORY_PAYLOAD_BOOL_KEY ,
8+ MANDATORY_PAYLOAD_TIMESTAMP_KEY , TEXT_PAYLOAD_KEY , TestNamedVectors , UUID_PAYLOAD_KEY ,
79 random_dense_vector, random_filter, random_payload, random_sparse_vector,
810} ;
11+
912use qdrant_client:: Qdrant ;
1013use qdrant_client:: qdrant:: payload_index_params:: IndexParams ;
1114use qdrant_client:: qdrant:: point_id:: PointIdOptions ;
1215use qdrant_client:: qdrant:: vectors_config:: Config :: ParamsMap ;
1316use qdrant_client:: qdrant:: {
14- CollectionInfo , CountPointsBuilder , CreateCollectionBuilder , CreateFieldIndexCollectionBuilder ,
15- CreateSnapshotResponse , DeletePointsBuilder , DeleteSnapshotRequestBuilder ,
16- DeleteSnapshotResponse , FieldType , GetPointsBuilder , GetResponse , OptimizersConfigDiff ,
17- PointId , PointStruct , Query , QueryBatchPointsBuilder , QueryBatchResponse , QueryPoints ,
18- ReplicaState , SetPayloadPointsBuilder , SparseVectorConfig , UpsertPointsBuilder , Vector ,
19- VectorInput , VectorParamsMap , Vectors , VectorsConfig , WriteOrdering ,
17+ BoolIndexParamsBuilder , CollectionInfo , CountPointsBuilder , CreateCollectionBuilder ,
18+ CreateFieldIndexCollectionBuilder , CreateSnapshotResponse , DatetimeIndexParamsBuilder ,
19+ DeletePointsBuilder , DeleteSnapshotRequestBuilder , DeleteSnapshotResponse , FieldType ,
20+ FloatIndexParamsBuilder , GeoIndexParamsBuilder , GetPointsBuilder , GetResponse ,
21+ IntegerIndexParamsBuilder , KeywordIndexParamsBuilder , OptimizersConfigDiff , PointId ,
22+ PointStruct , Query , QueryBatchPointsBuilder , QueryBatchResponse , QueryPoints , ReplicaState ,
23+ SetPayloadPointsBuilder , SparseVectorConfig , TextIndexParamsBuilder , TokenizerType ,
24+ UpsertPointsBuilder , UuidIndexParamsBuilder , Vector , VectorInput , VectorParamsMap , Vectors ,
25+ VectorsConfig , WriteOrdering ,
2026} ;
2127use qdrant_client:: qdrant:: { Filter , SnapshotDescription } ;
2228use rand:: Rng ;
@@ -237,6 +243,12 @@ pub async fn query_batch_points(
237243 Ok ( response)
238244}
239245
246+ /// Delete collection
247+ pub async fn delete_collection ( client : & Qdrant , collection_name : & str ) -> Result < ( ) , CrasherError > {
248+ client. delete_collection ( collection_name) . await ?;
249+ Ok ( ( ) )
250+ }
251+
240252/// Create collection
241253pub async fn create_collection (
242254 client : & Qdrant ,
@@ -428,6 +440,127 @@ pub async fn create_field_index(
428440 Ok ( ( ) )
429441}
430442
443+ pub async fn create_payload_indexes (
444+ client : & Qdrant ,
445+ collection_name : & str ,
446+ ) -> Result < ( ) , CrasherError > {
447+ // create keyword index for the payload
448+ create_field_index (
449+ client,
450+ collection_name,
451+ KEYWORD_PAYLOAD_KEY ,
452+ FieldType :: Keyword ,
453+ KeywordIndexParamsBuilder :: default ( )
454+ . is_tenant ( true )
455+ . on_disk ( true ) ,
456+ )
457+ . await ?;
458+
459+ // create integer index for the payload
460+ create_field_index (
461+ client,
462+ collection_name,
463+ INTEGER_PAYLOAD_KEY ,
464+ FieldType :: Integer ,
465+ IntegerIndexParamsBuilder :: new ( true , true )
466+ . is_principal ( true )
467+ . on_disk ( true ) ,
468+ )
469+ . await ?;
470+
471+ // create float index for the payload
472+ create_field_index (
473+ client,
474+ collection_name,
475+ FLOAT_PAYLOAD_KEY ,
476+ FieldType :: Float ,
477+ FloatIndexParamsBuilder :: default ( )
478+ . is_principal ( true )
479+ . on_disk ( true ) ,
480+ )
481+ . await ?;
482+
483+ // create geo index for the payload
484+ create_field_index (
485+ client,
486+ collection_name,
487+ GEO_PAYLOAD_KEY ,
488+ FieldType :: Geo ,
489+ GeoIndexParamsBuilder :: default ( ) . on_disk ( true ) ,
490+ )
491+ . await ?;
492+
493+ // create text payload index
494+ create_field_index (
495+ client,
496+ collection_name,
497+ TEXT_PAYLOAD_KEY ,
498+ FieldType :: Text ,
499+ TextIndexParamsBuilder :: new ( TokenizerType :: Multilingual )
500+ . ascii_folding ( true )
501+ . snowball_stemmer ( "english" . to_string ( ) )
502+ . stopwords_language ( "english" . to_string ( ) )
503+ . phrase_matching ( true )
504+ . on_disk ( true ) ,
505+ )
506+ . await ?;
507+
508+ // create boolean index for the payload
509+ create_field_index (
510+ client,
511+ collection_name,
512+ BOOL_PAYLOAD_KEY ,
513+ FieldType :: Bool ,
514+ BoolIndexParamsBuilder :: new ( ) . on_disk ( true ) ,
515+ )
516+ . await ?;
517+
518+ // create timestamp index for payload
519+ create_field_index (
520+ client,
521+ collection_name,
522+ DATETIME_PAYLOAD_KEY ,
523+ FieldType :: Datetime ,
524+ DatetimeIndexParamsBuilder :: default ( )
525+ . is_principal ( true )
526+ . on_disk ( true ) ,
527+ )
528+ . await ?;
529+
530+ // create UUID index for the payload
531+ create_field_index (
532+ client,
533+ collection_name,
534+ UUID_PAYLOAD_KEY ,
535+ FieldType :: Uuid ,
536+ UuidIndexParamsBuilder :: default ( )
537+ . is_tenant ( true )
538+ . on_disk ( true ) ,
539+ )
540+ . await ?;
541+
542+ // mandatory payload field indices
543+ create_field_index (
544+ client,
545+ collection_name,
546+ MANDATORY_PAYLOAD_TIMESTAMP_KEY ,
547+ FieldType :: Datetime ,
548+ DatetimeIndexParamsBuilder :: default ( )
549+ . is_principal ( true )
550+ . on_disk ( true ) ,
551+ )
552+ . await ?;
553+ create_field_index (
554+ client,
555+ collection_name,
556+ MANDATORY_PAYLOAD_BOOL_KEY ,
557+ FieldType :: Bool ,
558+ BoolIndexParamsBuilder :: default ( ) . on_disk ( true ) ,
559+ )
560+ . await ?;
561+ Ok ( ( ) )
562+ }
563+
431564/// Set payload (blocking)
432565///
433566/// Expects the `point_id` to exist.
0 commit comments