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

client.recreate_collection(
    collection_name="my_collection",
    vector_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.9.2.tar.gz (47.8 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.9.2-py3-none-any.whl (61.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for qdrant_client-0.9.2.tar.gz
Algorithm Hash digest
SHA256 4a2bc8c81aab64c49049d18dadd49ada136ee8aac5c07628c43d12f03bac71ba
MD5 a9094e047690d75a90163027f71a88a2
BLAKE2b-256 113bf652182107d4530653c5b23d110fb99290adedb927f3b613d6f1386bb222

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for qdrant_client-0.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 09ff9cd7cf6cfa4051939ca6e1e2a94bde0c297ca94ee2c91a6b3a88cbd45494
MD5 7410e00ce97ef934313fefd67f4e3fd5
BLAKE2b-256 37eb09e5e001e1cd5f6f320289f22759be5fa106a4769079c05a4138e06fbc9a

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