Skip to main content

A Qdrant-first ODM for typed models, schema sync, and vector search.

Project description

📦 Qdrant ODM (v0.3.0)

qdrant-odm is a Qdrant-first ODM for building production-grade vector search systems.


🚀 Features

  • Declarative schema (Pydantic-based)
  • Explicit payload indexing with fine-grained control
  • Collection modes (global / multitenant)
  • Safe schema sync (diff → plan → sync)
  • Python-native filter DSL
  • Async repository abstraction
  • Hybrid retrieval (dense + sparse with RRF)
  • Batch optimized operations

🚀 Installation

pip install -e ".[dev]"

🧠 Architecture Overview

Model → Metadata → SchemaManager → Qdrant
     ↘ Query DSL → Compiler → Filter
     ↘ Repository → CRUD / Search

📌 Model Definition

Basic Model

from uuid import UUID
from datetime import datetime
from qdrant_odm import QdrantModel, PayloadField, VectorField

class Document(QdrantModel):
    __collection__ = "documents"

    id: UUID
    title: str = PayloadField(index="keyword")
    created_at: datetime = PayloadField(index="datetime")

    dense = VectorField(name="content_dense", size=3072)

📌 Collection Modes

Global (default)

__collection_config__ = CollectionConfig(mode="global")

Multitenant

from qdrant_odm import CollectionConfig, KeywordIndexOptions

__collection_config__ = CollectionConfig(mode="multitenant")

tenant_id: str = PayloadField(
    index="keyword",
    keyword=KeywordIndexOptions(is_tenant=True)
)

Rules

  • Exactly ONE tenant index
  • Must be keyword
  • Must set is_tenant=True

📌 Vector Definition

VectorField(
    name="content_dense",
    size=3072,
    distance="Cosine"
)

Supported distances

  • Cosine
  • Euclid
  • Dot
  • Manhattan

📌 Payload Index Options

from qdrant_odm import IntegerIndexOptions

page: int = PayloadField(
    index="integer",
    integer=IntegerIndexOptions(
        lookup=True,
        range=True,
        on_disk=True
    )
)

Supported:

  • keyword
  • integer
  • float
  • bool
  • geo
  • datetime
  • text
  • uuid

🔍 Query DSL

(Document.category == "law") & (Document.page >= 2)

Supports:

  • == != > >= < <=
  • in_ / not_in
  • is_null / is_not_null
  • &, |, ~

📦 Repository

repo = QdrantRepository(client, Document)

CRUD

await repo.get(id)
await repo.delete(id)
await repo.exists(id)

Batch

await repo.upsert_many([...])

Scroll

page = await repo.scroll()

🔍 Search

Dense

await repo.search(SearchQuery(...))

Sparse

SparseVectorInput(indices=[...], values=[...])

Hybrid

await repo.search_hybrid(HybridSearchQuery(...))

Uses RRF internally.


🧬 Schema Sync

Diff

await odm.schema.diff(Model)

Dry Run

await odm.schema.dry_run(Model)

Sync

await odm.sync_schema(Model)

⚠️ Behavior Rules

Safe Sync

Will NOT modify:

  • vector schema
  • index type
  • index options

Only:

  • create collection
  • create missing indexes

Payload Behavior

  • upsert → model fields only
  • set_payload → free form

Filtering

  • Works without index
  • Slower without index

⚡ Performance Tips

  • Always index filter fields
  • Use batch operations
  • Use scroll for large datasets
  • Use hybrid search for recall boost

🔥 Summary

  • Qdrant-native ODM
  • strict schema guarantees
  • multitenant ready
  • production-ready async design

Project details


Download files

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

Source Distribution

qdrant_odmx-0.3.0.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

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

qdrant_odmx-0.3.0-py3-none-any.whl (32.9 kB view details)

Uploaded Python 3

File details

Details for the file qdrant_odmx-0.3.0.tar.gz.

File metadata

  • Download URL: qdrant_odmx-0.3.0.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for qdrant_odmx-0.3.0.tar.gz
Algorithm Hash digest
SHA256 80985aa6ec0b1dec60193c1d26393be135b78e99590e468abb5b258c18fd2a9a
MD5 77840a5ba9eeddc1e0f339cc929c1c8d
BLAKE2b-256 67c2ef6b285a7a2873e232a51490e676dd65ee736ef2bc2f2d10188a26b9c18b

See more details on using hashes here.

File details

Details for the file qdrant_odmx-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: qdrant_odmx-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 32.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for qdrant_odmx-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6deec93339071f8c854ec851a20030aa961e75de1864b08e5627714ea7bf1f74
MD5 c0a760be5257a517acedea1148342cc1
BLAKE2b-256 4cfd1b74552f75390e452da7f3f1b108b1b6f122d8b6be3be00e2ced13ef2d0a

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