Skip to content

Commit 7c5e9c9

Browse files
authored
Qdrant destination connector: how to create a compatible collection (#368)
1 parent 5de0da7 commit 7c5e9c9

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

snippets/general-shared-text/qdrant.mdx

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
- The name of the target [collection](https://qdrant.tech/documentation/concepts/collections) on the Qdrant local installation,
2-
Qdrant server, or Qdrant Cloud cluster.
31
- For [Qdrant local](https://github.com/qdrant/qdrant), the path to the local Qdrant installation, for example: `/qdrant/local`
42
- For [Qdrant client-server](https://qdrant.tech/documentation/quickstart/), the Qdrant server URL, for example: `http://localhost:6333`
53
- For [Qdrant Cloud](https://qdrant.tech/documentation/cloud-intro/):
@@ -14,3 +12,35 @@
1412
4. Note the value of the **Endpoint** field, for example: `https://<random-guid>.<region-id>.<cloud-provider>.cloud.qdrant.io`.
1513

1614
- A [Qdrant API key](https://qdrant.tech/documentation/cloud/authentication/#create-api-keys).
15+
16+
- The name of the target [collection](https://qdrant.tech/documentation/concepts/collections) on the Qdrant local installation,
17+
Qdrant server, or Qdrant Cloud cluster.
18+
19+
Qdrant requires the target collection to exist before Unstructured can write to the collection.
20+
The following example code demonstrates the use of the [Python Qdrant Client](https://pypi.org/project/qdrant-client/) to create
21+
a collection on a Qdrant Cloud cluster, configuring the collection for vectors with 3072 dimensions:
22+
23+
```python Python
24+
from qdrant_client import QdrantClient, models
25+
import os
26+
27+
client = QdrantClient(
28+
url=os.getenv("QDRANT_URL"),
29+
api_key=os.getenv("QDRANT_API_KEY")
30+
)
31+
32+
client.create_collection(
33+
collection_name=os.getenv("QDRANT_COLLECTION"),
34+
vectors_config=models.VectorParams(
35+
size=3072,
36+
distance=models.Distance.COSINE
37+
)
38+
)
39+
40+
collection = client.get_collection(
41+
collection_name=os.getenv("QDRANT_COLLECTION")
42+
)
43+
44+
print(f"The collection named '{os.getenv("QDRANT_COLLECTION")}' exists and " +
45+
f"has a status of '{collection.status}'.")
46+
```

0 commit comments

Comments
 (0)