@@ -81,6 +81,7 @@ def _init_storage(
8181 config .collection_name = self ._tmp_collection_name ()
8282
8383 self ._n_dim = config .n_dim
84+ self ._distance = config .distance
8485 self ._serialize_config = config .serialize_config
8586
8687 self ._client = QdrantClient (host = config .host , port = config .port )
@@ -134,17 +135,17 @@ def _initialize_qdrant_schema(self):
134135 m = self ._config .m ,
135136 )
136137 self .client .http .collections_api .create_collection (
137- self .collection_name ,
138- CreateCollection (
139- vector_size = self .n_dim ,
140- distance = self .distance ,
138+ collection_name = self .collection_name ,
139+ create_collection = CreateCollection (
140+ vector_size = self ._n_dim ,
141+ distance = DISTANCES [ self ._distance ] ,
141142 hnsw_config = hnsw_config ,
142143 ),
143144 )
144145
145146 def _collection_exists (self , collection_name ):
146- resp = self .client .http . collections_api . get_collections ()
147- collections = [collection .name for collection in resp .result . collections ]
147+ resp = self .client .get_collections ()
148+ collections = [collection .name for collection in resp .collections ]
148149 return collection_name in collections
149150
150151 @staticmethod
@@ -170,15 +171,14 @@ def __setstate__(self, state):
170171 def _get_offset2ids_meta (self ) -> List [str ]:
171172 if not self ._collection_exists (self .collection_name_meta ):
172173 return []
173- return self .client .http .points_api .get_point (
174- self .collection_name_meta , id = 1
175- ).result .payload ['offset2id' ]
174+ return self .client .retrieve (collection_name = self .collection_name_meta , ids = [1 ])
176175
177176 def _update_offset2ids_meta (self ):
178177 if not self ._collection_exists (self .collection_name_meta ):
179- self .client .http . collections_api . create_collection (
178+ self .client .recreate_collection (
180179 self .collection_name_meta ,
181- CreateCollection (vector_size = 1 , distance = Distance .COSINE ),
180+ vector_size = 1 ,
181+ distance = Distance .COSINE ,
182182 )
183183
184184 self .client .http .points_api .upsert_points (
0 commit comments