Skip to main content

A generic Python ORM-like base class for building models backed by Xapiand

Project description

xapian_model

A generic Python ORM-like base class for building models backed by Xapiand, a distributed search engine. Part of the Dubalu Framework.

Features

  • Fully async — All Xapiand operations use async/await (powered by pyxapiand>=2.0.0 and httpx).
  • BaseXapianModel — Base class with attribute interception, save/delete operations, and template-based dynamic index naming.
  • Manager — Descriptor-based manager providing create(), get(), and filter() query methods.
  • SearchResults — Dataclass wrapping search results with total counts and aggregations.
  • Schema auto-provisioning — Automatically provisions the schema on first write.

Installation

pip install xapian-model

Dependencies

Requires pyxapiand 2.0.0+ (async client):

pip install "pyxapiand>=2.0.0"

Quick Start

import asyncio
from xapian_model.base import BaseXapianModel

class Product(BaseXapianModel):
    INDEX_TEMPLATE = "products/{store_id}"
    SCHEMA = {
        "name": {"_type": "text"},
        "price": {"_type": "float"},
        "active": {"_type": "boolean", "_default": True},
    }

async def main():
    # Create a product
    product = await Product.objects.create(store_id="store1", name="Widget", price=9.99)

    # Retrieve by ID
    product = await Product.objects.get(id="abc123", store_id="store1")

    # Search
    results = await Product.objects.filter(query="widget", store_id="store1", limit=10)
    for item in results.results:
        print(item.name, item.price)

    # Update and save
    product.price = 12.99
    await product.save()

    # Delete
    await product.delete()

asyncio.run(main())

Requirements

License

MIT — Copyright (c) 2026 Dubalu International

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

xapian_model-0.3.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

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

xapian_model-0.3.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for xapian_model-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0a90ac08bd247cfb9aae31ad4f94209feedba9232bf0ec21114fcec8769ae528
MD5 0bbd7f9e639eb6e4bdcfe51e226dfa93
BLAKE2b-256 ec6ba647c748097dbd472ceb456a3613b51d2bda48e1a64fa82475451d912f3a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for xapian_model-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc1214cf2ce20f74064a8a84f40131bf0b4782b7efd46e0913e05a43187d6d6d
MD5 afffc0eb7289d22f2fca6fbbe501fe4a
BLAKE2b-256 bf6bb02fe1009ec86f35fbeb564c9cca82a423b5fec662d86b40bfe85851c963

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