Skip to main content

Client library for the Qdrant vector search engine

Project description

Python Qdrant client library

Client library for the 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 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

from qdrant_client import QdrantClient

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

Create a new collection

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

my_collection_info = client.http.collections_api.get_collection("my_collection")
print(my_collection_info.dict())

Search for similar vectors

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

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

gRPC

gRPC support in Qdrant client is under active development. Basic classes could be found here.

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

from qdrant_client import QdrantClient

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

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qdrant_client-0.11.1.tar.gz (66.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qdrant_client-0.11.1-py3-none-any.whl (87.3 kB view details)

Uploaded Python 3

File details

Details for the file qdrant_client-0.11.1.tar.gz.

File metadata

  • Download URL: qdrant_client-0.11.1.tar.gz
  • Upload date:
  • Size: 66.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for qdrant_client-0.11.1.tar.gz
Algorithm Hash digest
SHA256 59d84f71254ada0773734a18e5bc27341003e1ae1aef35168315f4f158e19104
MD5 781255a5b101289a43d329fa569e434e
BLAKE2b-256 602ce8ff054c244b3b761250c7f78642a3b1da047441e1792006c43e816c36f1

See more details on using hashes here.

File details

Details for the file qdrant_client-0.11.1-py3-none-any.whl.

File metadata

  • Download URL: qdrant_client-0.11.1-py3-none-any.whl
  • Upload date:
  • Size: 87.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for qdrant_client-0.11.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b0246f7be5796c262d6fc08c91a5b1ebdb2b256d74903943c0703be196733caa
MD5 ff6b2ec58b5f6d419eaf6ff989388372
BLAKE2b-256 7453153a179de3d2c71d233897e6a5c4a7d5a5a9358ca89b8ad9cd29ddf7d773

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page