Skip to main content

qx-search

OpenSearch/Elasticsearch async client and repository abstraction for the Qx framework.

What lives here

  • qx.search.SearchRepository[TDoc] — abstract base class for document repositories. Implement index_name and to_document / from_document mapping; the base provides index, get, delete, and search methods.
  • qx.search.SearchQuery — composable query builder: full-text query, filters, sort, pagination offset, and highlight options.
  • qx.search.SearchHit[TDoc] — single search result with the mapped document, score, and raw _source.
  • qx.search.SearchSettings — Pydantic settings for the OpenSearch/Elasticsearch endpoint URL and optional auth.
  • qx.search.create_search_client — async factory that opens an AsyncOpenSearch connection.
  • qx.search.ensure_index / drop_index — index lifecycle helpers; ensure_index creates an index with provided mapping if it doesn't exist (idempotent).

Usage

from qx.search import SearchRepository, SearchQuery, SearchSettings, create_search_client

class ProductSearchRepository(SearchRepository[ProductDoc]):
    index_name = "products"

    def to_document(self, product: Product) -> dict:
        return {"id": str(product.id), "name": product.name, "sku": product.sku}

    def from_document(self, doc: dict) -> ProductDoc:
        return ProductDoc(**doc)


# Bootstrap
client = await create_search_client(settings.search)
repo = ProductSearchRepository(client)

# Index a document
await repo.index(product)

# Search
hits = await repo.search(SearchQuery(q="widget", filters={"category": "tools"}, size=20))

Design rules

  • SearchRepository intentionally does not extend qx.db.Repository — search is a read projection, not the system of record. Write to the DB first, sync to search via an integration event handler.
  • ensure_index is safe to call at startup on every deploy; it is a no-op if the index already exists with a compatible mapping.
  • This package is a V2 scope item. The InMemorySearchRepository test double lives in qx-testing.

Metadata

Release files for qx-search 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qx-search 1.1.0
File Size Uploaded Provenance Actions
qx_search-1.1.0.tar.gz 8.7 kB Without provenance Details for qx_search-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for qx-search 1.1.0
File Interpreter ABI Platform Actions
qx_search-1.1.0-py3-none-any.whl Python 3 none any Details for qx_search-1.1.0-py3-none-any.whl

Total release size: 16.8 kB

Release files / qx_search-1.1.0.tar.gz

Download URL qx_search-1.1.0.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bb266dad4d92e92604480850622ee9efa92870937a0b654add2c6faf565c837a
BLAKE2b-256 checksum
How to use checksums
017b9e7e0fa0e2a725045445459104b69f42f35d98e04e51951621967a4858e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / qx_search-1.1.0-py3-none-any.whl

Download URL qx_search-1.1.0-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
146443705a763ee26a8ef3fcfb3858bc31345c504982df6c3519488402216fb5
BLAKE2b-256 checksum
How to use checksums
d56782274ef978c87a900ddf6875abf579f07db310ce3085cd9cebf31097507f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Security for qx-search 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page