Metadata-Version: 2.1
Name: qdrant-client
Version: 0.11.7
Summary: Client library for the Qdrant vector search engine
Home-page: https://github.com/qdrant/qdrant_client
Keywords: vector,search,neural,matching,client
Author: Andrey Vasnetsov
Author-email: andrey@qdrant.tech
Requires-Python: >=3.7,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: grpcio (>=1.41.0)
Requires-Dist: grpcio-tools (>=1.41.0)
Requires-Dist: httpx[http2] (>=0.14.0)
Requires-Dist: numpy (>=1.21)
Requires-Dist: pydantic (>=1.8,<2.0)
Requires-Dist: typing-extensions (>=4.0.0,<5.0.0)
Project-URL: Repository, https://github.com/qdrant/qdrant_client
Description-Content-Type: text/markdown

# Python Qdrant client library 

Client library for the [Qdrant](https://github.com/qdrant/qdrant) vector search engine.

Library contains type definitions for all Qdrant API and allows to make both Sync and Async requests.

`Pydantic` is used for describing request models and `httpx` for handling http queries.

Client allows calls for all [Qdrant API methods](https://qdrant.github.io/qdrant/redoc/index.html) directly.
It also provides some additional helper methods for frequently required operations, e.g. initial collection uploading.

## Installation

```
pip install qdrant-client
```

## Examples



Instance a client
```python
from qdrant_client import QdrantClient

client = QdrantClient(host="localhost", port=6333)
```

Create a new collection
```python
from qdrant_client.http.models import Distance, VectorParams

client.recreate_collection(
    collection_name="my_collection",
    vectors_config=VectorParams(size=100, distance=Distance.COSINE),
)
```

Get info about created collection
```python
my_collection_info = client.http.collections_api.get_collection("my_collection")
print(my_collection_info.dict())
```

Search for similar vectors

```python
query_vector = np.random.rand(100)
hits = client.search(
    collection_name="my_collection",
    query_vector=query_vector,
    query_filter=None,  # Don't use any filters for now, search across all indexed points
    append_payload=True,  # Also return a stored payload for found points
    top=5  # Return 5 closest points
)
```

Search for similar vectors with filtering condition

```python
from qdrant_client.http.models import Filter, FieldCondition, Range

hits = client.search(
    collection_name="my_collection",
    query_vector=query_vector,
    query_filter=Filter(
        must=[  # These conditions are required for search results
            FieldCondition(
                key='rand_number',  # Condition based on values of `rand_number` field.
                range=Range(
                    gte=0.5  # Select only those results where `rand_number` >= 0.5
                )
            )
        ]
    ),
    append_payload=True,  # Also return a stored payload for found points
    top=5  # Return 5 closest points
)
```

Check out [full example code](tests/test_qdrant_client.py)

### gRPC

gRPC support in Qdrant client is under active development.
Basic classes could be found [here](qdrant_client/grpc/__init__.py).

To enable (much faster) collection uploading with gRPC, use the following initialization:

```python
from qdrant_client import QdrantClient

client = QdrantClient(host="localhost", grpc_port=6334, prefer_grpc=True)
```

