@@ -21,6 +21,13 @@ class QdrantConfigurator(BaseConfigurator):
2121 "float" : rest .PayloadSchemaType .FLOAT ,
2222 "geo" : rest .PayloadSchemaType .GEO ,
2323 }
24+ INDEX_PARAMS_TYPE_MAPPING = {
25+ "int" : rest .IntegerIndexParams ,
26+ "keyword" : rest .KeywordIndexParams ,
27+ "text" : rest .TextIndexParams ,
28+ "float" : rest .FloatIndexParams ,
29+ "geo" : rest .GeoIndexParams ,
30+ }
2431
2532 def __init__ (self , host , collection_params : dict , connection_params : dict ):
2633 super ().__init__ (host , collection_params , connection_params )
@@ -43,15 +50,25 @@ def recreate(self, dataset: Dataset, collection_params):
4350 },
4451 }
4552 else :
53+ is_vectors_on_disk = self .collection_params .get ("vectors_config" , {}).get (
54+ "on_disk" , False
55+ )
56+ self .collection_params .pop ("vectors_config" , None )
57+
4658 vectors_config = {
4759 "vectors_config" : (
4860 rest .VectorParams (
4961 size = dataset .config .vector_size ,
5062 distance = self .DISTANCE_MAPPING .get (dataset .config .distance ),
63+ on_disk = is_vectors_on_disk ,
5164 )
5265 )
5366 }
5467
68+ payload_index_params = self .collection_params .pop ("payload_index_params" , {})
69+ if not set (payload_index_params .keys ()).issubset (dataset .config .schema .keys ()):
70+ raise ValueError ("payload_index_params are not found in dataset schema" )
71+
5572 self .client .recreate_collection (
5673 collection_name = QDRANT_COLLECTION_NAME ,
5774 ** vectors_config ,
@@ -65,8 +82,24 @@ def recreate(self, dataset: Dataset, collection_params):
6582 ),
6683 )
6784 for field_name , field_type in dataset .config .schema .items ():
68- self .client .create_payload_index (
69- collection_name = QDRANT_COLLECTION_NAME ,
70- field_name = field_name ,
71- field_schema = self .INDEX_TYPE_MAPPING .get (field_type ),
72- )
85+ if field_type in ["keyword" , "uuid" ]:
86+ is_tenant = payload_index_params .get (field_name , {}).get (
87+ "is_tenant" , None
88+ )
89+ on_disk = payload_index_params .get (field_name , {}).get ("on_disk" , None )
90+
91+ self .client .create_payload_index (
92+ collection_name = QDRANT_COLLECTION_NAME ,
93+ field_name = field_name ,
94+ field_schema = self .INDEX_PARAMS_TYPE_MAPPING .get (field_type )(
95+ type = self .INDEX_TYPE_MAPPING .get (field_type ),
96+ is_tenant = is_tenant ,
97+ on_disk = on_disk ,
98+ ),
99+ )
100+ else :
101+ self .client .create_payload_index (
102+ collection_name = QDRANT_COLLECTION_NAME ,
103+ field_name = field_name ,
104+ field_schema = self .INDEX_TYPE_MAPPING .get (field_type ),
105+ )
0 commit comments