mirror of
https://github.com/qdrant/landing_page.git
synced 2026-09-28 15:38:33 +02:00
Apply suggestions from code review
Co-authored-by: Steven Pousty <steve.pousty@gmail.com>
This commit is contained in:
co-authored by
Steven Pousty
parent
9c734a9634
commit
d536b40da6
@@ -34,8 +34,10 @@ in a Docker container:
|
||||
docker run -p "6333:6333" -p "6334:6334" qdrant/qdrant:v1.4.0
|
||||
```
|
||||
|
||||
Alternatively, you can also use a [Qdrant Cloud](https://cloud.qdrant.io/) cluster. In this case, you need to pass the API key to the
|
||||
client constructor. No matter which way you choose, the `QdrantClient` instance has to be created:
|
||||
Alternatively, you can also use a [Qdrant Cloud](https://cloud.qdrant.io/) cluster. With a Cloud cluster you will pass the API key to the
|
||||
client constructor.
|
||||
|
||||
With that, we are ready to create `QdrantClient` instance:
|
||||
|
||||
```python
|
||||
from qdrant_client import QdrantClient
|
||||
@@ -45,7 +47,7 @@ client = QdrantClient("localhost")
|
||||
# client = QdrantClient("https://your-cluster-url.cloud.com", api_key="your-api-key")
|
||||
```
|
||||
|
||||
The top-level client exposes just the synchronous methods. We can access the autogenerated async clients and call the underlying methods.
|
||||
The default client only exposes the synchronous methods for interacting with the server. To access the async client and it's underlying methods, we need to use autogenerated async clients.
|
||||
It is possible to use asynchronous HTTP API by using `qdrant_client.http.api_client.AsyncApiClient`. However, the gRPC API is much more
|
||||
efficient and is the recommended way of using Qdrant asynchronously.
|
||||
|
||||
@@ -90,7 +92,7 @@ response = await client.async_grpc_collections.Create(
|
||||
```
|
||||
|
||||
Our collection was set up for 100-dimensional vectors, cosine distance and 8-bit quantization. The timeout is set to 10 seconds, so
|
||||
if the server does not respond in this time, the request will be aborted.
|
||||
if the server does not respond within 10 seconds, the request will be aborted.
|
||||
|
||||
#### Checking collection info
|
||||
|
||||
@@ -227,12 +229,11 @@ await client.async_grpc_collections.Delete(
|
||||
)
|
||||
```
|
||||
|
||||
That's it when it comes to collection management. Let's move on to points, as semantic search requires us to have some vectors in the
|
||||
collection.
|
||||
That's it when it comes to collection management. Let's move on to points (individual vectors) allowing us to load data into our collection
|
||||
|
||||
#### Adding points to the collection
|
||||
|
||||
Before we add any points, please make sure the collection is created, as we did in one of the previous steps. If so, we can add some
|
||||
Assuming your collection created successfuly, we can now add some
|
||||
points to it. Let's add our first two points into the collection:
|
||||
|
||||
```python
|
||||
@@ -269,7 +270,7 @@ response = await client.async_grpc_points.Upsert(
|
||||
)
|
||||
```
|
||||
|
||||
Those points are going to be indexed and available for search. We can add more points, or update the existing ones. All the point related
|
||||
Those points are automatically indexed and available for search. In the future, we can add more points, or update the existing ones. All the point related
|
||||
operations are [documented in the Qdrant server repository](https://github.com/qdrant/qdrant/blob/master/docs/grpc/docs.md#points_serviceproto).
|
||||
|
||||
The main operation we need from the vector database is semantic search. Let's see how to perform it.
|
||||
@@ -291,7 +292,7 @@ response = await client.async_grpc_points.Search(
|
||||
print(response)
|
||||
```
|
||||
|
||||
The response is going to contain just the point id and similarity score. For example, that might be the output of the code above:
|
||||
The response is going to contain just the point id and similarity score for the vector most similar to the random vector generated in the code. For example, that might be the output of the code above:
|
||||
|
||||
```text
|
||||
result {
|
||||
@@ -320,11 +321,11 @@ response = await client.async_grpc_points.Search(
|
||||
)
|
||||
```
|
||||
|
||||
Right now, our response is going to have both vector and payload.
|
||||
That's all the code you need to bring back the vector and payload.
|
||||
|
||||
##### Applying filters
|
||||
|
||||
If you ever used SQL, you are probably familiar with the `WHERE` clause. It allows you to filter the results of the query. Qdrant has a similar
|
||||
If you ever used SQL, you are probably familiar with the `WHERE` clause. It allows you to filter the results of the query. Qdrant has similar
|
||||
functionality. Let's say we want to find all the points similar to given vector, but with `int_param` equal to 32. We can do it like this:
|
||||
|
||||
```python
|
||||
@@ -348,7 +349,7 @@ response = await client.async_grpc_points.Search(
|
||||
)
|
||||
```
|
||||
|
||||
We can build even more sophisticated filters with the `must`, `should` and `must_not` clauses. You can find more details [in the
|
||||
We can build even more sophisticated filters with the `must`, `should` and `must_not` clauses. You can find more details in the [filtering
|
||||
documentation](https://qdrant.tech/documentation/concepts/filtering/#filtering).
|
||||
|
||||
Analogous to search, we can also [scroll our collection](https://qdrant.tech/documentation/concepts/points/#scroll-points) to retrieve all the
|
||||
|
||||
Reference in New Issue
Block a user