Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions docarray/array/storage/qdrant/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def _init_storage(
config.collection_name = self._tmp_collection_name()

self._n_dim = config.n_dim
self._distance = config.distance
self._serialize_config = config.serialize_config

self._client = QdrantClient(host=config.host, port=config.port)
Expand Down Expand Up @@ -134,17 +135,17 @@ def _initialize_qdrant_schema(self):
m=self._config.m,
)
self.client.http.collections_api.create_collection(
self.collection_name,
CreateCollection(
vector_size=self.n_dim,
distance=self.distance,
collection_name=self.collection_name,
create_collection=CreateCollection(
vector_size=self._n_dim,
distance=DISTANCES[self._distance],
hnsw_config=hnsw_config,
),
)

def _collection_exists(self, collection_name):
resp = self.client.http.collections_api.get_collections()
collections = [collection.name for collection in resp.result.collections]
resp = self.client.get_collections()
collections = [collection.name for collection in resp.collections]
return collection_name in collections

@staticmethod
Expand All @@ -170,15 +171,20 @@ def __setstate__(self, state):
def _get_offset2ids_meta(self) -> List[str]:
if not self._collection_exists(self.collection_name_meta):
return []
return self.client.http.points_api.get_point(
self.collection_name_meta, id=1
).result.payload['offset2id']
results = self.client.retrieve(
collection_name=self.collection_name_meta, ids=[1]
)
if len(results) == 0:
return []
else:
return results[0].payload.get('offset2id', [])

def _update_offset2ids_meta(self):
if not self._collection_exists(self.collection_name_meta):
self.client.http.collections_api.create_collection(
self.client.recreate_collection(
self.collection_name_meta,
CreateCollection(vector_size=1, distance=Distance.COSINE),
vector_size=1,
distance=Distance.COSINE,
)

self.client.http.points_api.upsert_points(
Expand Down
2 changes: 1 addition & 1 deletion docs/advanced/document-store/qdrant.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ server. Create `docker-compose.yml` as follows:
version: '3.4'
services:
qdrant:
image: qdrant/qdrant:v0.7.0
image: qdrant/qdrant:v0.8.0
ports:
- "6333:6333"
ulimits: # Only required for tests, as there are a lot of collections created
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
qdrant:
image: qdrant/qdrant:v0.7.0
image: qdrant/qdrant:v0.8.0
ports:
- "41233:41233"
ulimits: # Only required for tests, as there are a lot of collections created
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
'strawberry-graphql',
],
'qdrant': [
'qdrant-client~=0.7.3',
'qdrant-client==0.8.0',
],
'annlite': [
'annlite>=0.3.12',
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/array/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
qdrant:
image: qdrant/qdrant:v0.7.0
image: qdrant/qdrant:v0.8.0
ports:
- "6333:6333"
ulimits: # Only required for tests, as there are a lot of collections created
Expand Down